
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/polys/internals.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:59 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Internals of the Polynomial Manipulation Module &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="internals.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Series Manipulation using Polynomials" href="ringseries.html" />
    <link rel="prev" title="Reference docs for the Poly Domains" href="domainsref.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ringseries.html" title="Series Manipulation using Polynomials"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="domainsref.html" title="Reference docs for the Poly Domains"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Internals of the Polynomial Manipulation Module</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="internals-of-the-polynomial-manipulation-module">
<span id="polys-internals"></span><h1>Internals of the Polynomial Manipulation Module<a class="headerlink" href="#internals-of-the-polynomial-manipulation-module" title="Permalink to this headline">¶</a></h1>
<p>The implementation of the polynomials module is structured internally in
“levels”. There are four levels, called L0, L1, L2 and L3. The levels three
and four contain the user-facing functionality and were described in the
previous section. This section focuses on levels zero and one.</p>
<p>Level zero provides core polynomial manipulation functionality with C-like,
low-level interfaces. Level one wraps this low-level functionality into object
oriented structures. These are <em>not</em> the classes seen by the user, but rather
classes used internally throughout the polys module.</p>
<p>There is one additional complication in the implementation. This comes from the
fact that all polynomial manipulations are relative to a <em>ground domain</em>. For
example, when factoring a polynomial like <span class="math notranslate nohighlight">\(x^{10} - 1\)</span>, one has to decide what
ring the coefficients are supposed to belong to, or less trivially, what
coefficients are allowed to appear in the factorization. This choice of
coefficients is called a ground domain. Typical choices include the integers
<span class="math notranslate nohighlight">\(\mathbb{Z}\)</span>, the rational numbers <span class="math notranslate nohighlight">\(\mathbb{Q}\)</span> or various related rings and
fields. But it is perfectly legitimate (although in this case uninteresting)
to factorize over polynomial rings such as <span class="math notranslate nohighlight">\(k[Y]\)</span>, where <span class="math notranslate nohighlight">\(k\)</span> is some fixed
field.</p>
<p>Thus the polynomial manipulation algorithms (both
complicated ones like factoring, and simpler ones like addition or
multiplication) have to rely on other code to manipulate the coefficients.
In the polynomial manipulation module, such code is encapsulated in so-called
“domains”. A domain is basically a factory object: it takes various
representations of data, and converts them into objects with unified interface.
Every object created by a domain has to implement the arithmetic operations
<span class="math notranslate nohighlight">\(+\)</span>, <span class="math notranslate nohighlight">\(-\)</span> and <span class="math notranslate nohighlight">\(\times\)</span>. Other operations are accessed through the domain, e.g.
as in <code class="docutils literal notranslate"><span class="pre">ZZ.quo(ZZ(4),</span> <span class="pre">ZZ(2))</span></code>.</p>
<p>Note that there is some amount of <em>circularity</em>: the polynomial ring domains
use the level one classes, the level one classes use the level zero functions,
and level zero functions use domains. It is possible, in principle, but not in
the current implementation, to work in rings like <span class="math notranslate nohighlight">\(k[X][Y]\)</span>. This would create
even more layers. For this reason, working in the isomorphic ring <span class="math notranslate nohighlight">\(k[X, Y]\)</span>
is preferred.</p>
<section id="level-zero">
<h2>Level Zero<a class="headerlink" href="#level-zero" title="Permalink to this headline">¶</a></h2>
<p>Level zero contains the bulk code of the polynomial manipulation module.</p>
<section id="manipulation-of-dense-multivariate-polynomials">
<h3>Manipulation of dense, multivariate polynomials<a class="headerlink" href="#manipulation-of-dense-multivariate-polynomials" title="Permalink to this headline">¶</a></h3>
<p>These functions can be used to manipulate polynomials in <span class="math notranslate nohighlight">\(K[X_0, \ldots, X_u]\)</span>.
Functions for manipulating multivariate polynomials in the dense representation
have the prefix <code class="docutils literal notranslate"><span class="pre">dmp_</span></code>. Functions which only apply to univariate polynomials
(i.e. <span class="math notranslate nohighlight">\(u = 0\)</span>)
have the prefix <code class="docutils literal notranslate"><span class="pre">dup__</span></code>. The ground domain <span class="math notranslate nohighlight">\(K\)</span> has to be passed explicitly.
For many multivariate polynomial manipulation functions also the level <span class="math notranslate nohighlight">\(u\)</span>,
i.e. the number of generators minus one, has to be passed.
(Note that, in many cases, <code class="docutils literal notranslate"><span class="pre">dup_</span></code> versions of functions are available, which
may be slightly more efficient.)</p>
<p><strong>Basic manipulation:</strong></p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_LC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L11-L30"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">poly_LC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly_LC</span><span class="p">([],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly_LC</span><span class="p">([</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_TC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_TC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L33-L52"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_TC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return trailing coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">poly_TC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly_TC</span><span class="p">([],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly_TC</span><span class="p">([</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_ground_LC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L58-L78"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_ground_LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the ground leading coefficient.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_ground_LC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground_LC</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_ground_TC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_TC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L81-L101"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_ground_TC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the ground trailing coefficient.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_ground_TC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground_TC</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_true_LT">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_true_LT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L104-L131"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_true_LT" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading term <code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">*</span> <span class="pre">x_1**n_1</span> <span class="pre">...</span> <span class="pre">x_k**n_k</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_true_LT</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_true_LT</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">((2, 0), 4)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_degree">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_degree</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L157-L181"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_degree" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading degree of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">x_0</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p>Note that the degree of 0 is negative infinity (the SymPy object -oo).</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_degree</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_degree</span><span class="p">([[[]]],</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-oo</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_degree</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_degree_in">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_degree_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L194-L217"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_degree_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading degree of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">x_j</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_degree_in</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_degree_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_degree_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_degree_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_degree_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L231-L249"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_degree_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of degrees of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_degree_list</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_degree_list</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">(1, 2)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_strip">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_strip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L279-L309"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_strip" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove leading zeros from <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_strip</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_strip</span><span class="p">([[],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">]],</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[[0, 1, 2], [1]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_validate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_validate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L340-L366"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_validate" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the number of levels in <code class="docutils literal notranslate"><span class="pre">f</span></code> and recursively strip it.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_validate</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_validate</span><span class="p">([[],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">]])</span>
<span class="go">([[1, 2], [1]], 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_validate</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="mi">1</span><span class="p">])</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ValueError</span>: <span class="n">invalid data structure for a multivariate polynomial</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dup_reverse">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dup_reverse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L369-L385"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dup_reverse" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">x**n</span> <span class="pre">*</span> <span class="pre">f(1/x)</span></code>, i.e.: reverse <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dup_reverse</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dup_reverse</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">[3, 2, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_copy">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_copy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L407-L428"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new copy of a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_copy</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_copy</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[[1], [1, 2]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_to_tuple">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_to_tuple</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L452-L474"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_to_tuple" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert <span class="math notranslate nohighlight">\(f\)</span> into a nested tuple of tuples.</p>
<p>This is needed for hashing.  This is similar to dmp_copy().</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_to_tuple</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_to_tuple</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">((1,), (1, 2))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_normal">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_normal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L494-L513"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize a multivariate polynomial in the given domain.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_normal</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_normal</span><span class="p">([[],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">,</span> <span class="mi">2</span><span class="p">]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 2]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_convert">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_convert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K1</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L541-L567"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_convert" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the ground domain of <code class="docutils literal notranslate"><span class="pre">f</span></code> from <code class="docutils literal notranslate"><span class="pre">K0</span></code> to <code class="docutils literal notranslate"><span class="pre">K1</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.rings</span> <span class="kn">import</span> <span class="n">ring</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_convert</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_convert</span><span class="p">([[</span><span class="n">R</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">R</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">R</span><span class="o">.</span><span class="n">to_domain</span><span class="p">(),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1], [2]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_convert</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">R</span><span class="o">.</span><span class="n">to_domain</span><span class="p">())</span>
<span class="go">[[1], [2]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_from_sympy">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_from_sympy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L588-L608"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_from_sympy" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the ground domain of <code class="docutils literal notranslate"><span class="pre">f</span></code> from SymPy to <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_from_sympy</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_from_sympy</span><span class="p">([[</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]]</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_nth">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_nth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L637-L660"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_nth" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <code class="docutils literal notranslate"><span class="pre">n</span></code>-th coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_nth</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_nth</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_nth</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_ground_nth">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_nth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L663-L692"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_ground_nth" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the ground <code class="docutils literal notranslate"><span class="pre">n</span></code>-th coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_ground_nth</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground_nth</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_zero_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_zero_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L695-L717"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_zero_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is zero in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_zero_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_zero_p</span><span class="p">([[[[[]]]]],</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_zero_p</span><span class="p">([[[[[</span><span class="mi">1</span><span class="p">]]]]],</span> <span class="mi">4</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_zero">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_zero</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L720-L738"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_zero" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a multivariate zero.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_zero</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_zero</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
<span class="go">[[[[[]]]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_one_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_one_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L741-L755"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_one_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is one in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_one_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_one_p</span><span class="p">([[[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]]],</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_one">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_one</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L758-L772"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_one" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a multivariate one over <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_one</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_one</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[1]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_ground_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L775-L802"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_ground_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if <code class="docutils literal notranslate"><span class="pre">f</span></code> is constant in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_ground_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground_p</span><span class="p">([[[</span><span class="mi">3</span><span class="p">]]],</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground_p</span><span class="p">([[[</span><span class="mi">4</span><span class="p">]]],</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L805-L826"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a multivariate constant.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_ground</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">[[[[[[3]]]]]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_ground</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_zeros">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_zeros</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L829-L851"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_zeros" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of multivariate zeros.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_zeros</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[[]]], [[[]]], [[[]]]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[0, 0, 0]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_grounds">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_grounds</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L854-L876"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_grounds" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of multivariate constants.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_grounds</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_grounds</span><span class="p">(</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">[[[[4]]], [[[4]]], [[[4]]]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_grounds</span><span class="p">(</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="go">[4, 4, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_negative_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_negative_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L879-L895"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_negative_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code> is negative.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_negative_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_negative_p</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="o">-</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_negative_p</span><span class="p">([[</span><span class="o">-</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_positive_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_positive_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L898-L914"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_positive_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code> is positive.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_positive_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_positive_p</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="o">-</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_positive_p</span><span class="p">([[</span><span class="o">-</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_from_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_from_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L975-L1016"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> polynomial from a <code class="docutils literal notranslate"><span class="pre">dict</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_from_dict</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_from_dict</span><span class="p">({(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)},</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0], [], [2, 3]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_from_dict</span><span class="p">({},</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_to_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_to_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zero</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1071-L1103"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_to_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> polynomial to a <code class="docutils literal notranslate"><span class="pre">dict``</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_to_dict</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_to_dict</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]],</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">{(0, 0): 3, (0, 1): 2, (2, 1): 1}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_to_dict</span><span class="p">([],</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">{}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_swap">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_swap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1106-L1138"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_swap" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform <code class="docutils literal notranslate"><span class="pre">K[..x_i..x_j..]</span></code> to <code class="docutils literal notranslate"><span class="pre">K[..x_j..x_i..]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_swap</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]],</span> <span class="p">[]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_swap</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[2], []], [[1, 0], []]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_swap</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[1], [2, 0]], [[]]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_swap</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[1, 0]], [[2, 0], []]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_permute">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_permute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">P</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1141-L1169"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_permute" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a polynomial in <code class="docutils literal notranslate"><span class="pre">K[x_{P(1)},..,x_{P(n)}]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_permute</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]],</span> <span class="p">[]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_permute</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[2], []], [[1, 0], []]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_permute</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[1], []], [[2, 0], []]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_nest">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_nest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1172-L1192"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_nest" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a multivariate value nested <code class="docutils literal notranslate"><span class="pre">l</span></code>-levels.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_nest</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_nest</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[[1]]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_raise">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_raise</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1195-L1224"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_raise" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a multivariate polynomial raised <code class="docutils literal notranslate"><span class="pre">l</span></code>-levels.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_raise</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_raise</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[[]]], [[[1]], [[2]]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_deflate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_deflate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1260-L1301"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_deflate" title="Permalink to this definition">¶</a></dt>
<dd><p>Map <code class="docutils literal notranslate"><span class="pre">x_i**m_i</span></code> to <code class="docutils literal notranslate"><span class="pre">y_i</span></code> in a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_deflate</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_deflate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">((2, 3), [[1, 2], [3, 4]])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_multi_deflate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_multi_deflate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">polys</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1343-L1396"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_multi_deflate" title="Permalink to this definition">¶</a></dt>
<dd><p>Map <code class="docutils literal notranslate"><span class="pre">x_i**m_i</span></code> to <code class="docutils literal notranslate"><span class="pre">y_i</span></code> in a set of polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_multi_deflate</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_multi_deflate</span><span class="p">((</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">((2, 1), ([[1, 0, 0, 2], [3, 0, 0, 4]], [[1, 0, 2], [3, 0, 4]]))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_inflate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_inflate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1451-L1473"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_inflate" title="Permalink to this definition">¶</a></dt>
<dd><p>Map <code class="docutils literal notranslate"><span class="pre">y_i</span></code> to <code class="docutils literal notranslate"><span class="pre">x_i**k_i</span></code> in a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_inflate</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_inflate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0, 0, 2], [], [3, 0, 0, 4]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_exclude">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_exclude</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1476-L1521"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_exclude" title="Permalink to this definition">¶</a></dt>
<dd><p>Exclude useless levels from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Return the levels excluded, the new excluded <code class="docutils literal notranslate"><span class="pre">f</span></code>, and the new <code class="docutils literal notranslate"><span class="pre">u</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_exclude</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[[</span><span class="mi">1</span><span class="p">]],</span> <span class="p">[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">]]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_exclude</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">([2], [[1], [1, 2]], 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_include">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_include</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">J</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1524-L1555"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_include" title="Permalink to this definition">¶</a></dt>
<dd><p>Include useless levels in <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_include</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_include</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[[1]], [[1], [2]]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_inject">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_inject</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">front</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1558-L1592"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_inject" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert <code class="docutils literal notranslate"><span class="pre">f</span></code> from <code class="docutils literal notranslate"><span class="pre">K[X][Y]</span></code> to <code class="docutils literal notranslate"><span class="pre">K[X,Y]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.rings</span> <span class="kn">import</span> <span class="n">ring</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_inject</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_inject</span><span class="p">([</span><span class="n">R</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="n">R</span><span class="o">.</span><span class="n">to_domain</span><span class="p">())</span>
<span class="go">([[[1]], [[1], [2]]], 2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_inject</span><span class="p">([</span><span class="n">R</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="n">R</span><span class="o">.</span><span class="n">to_domain</span><span class="p">(),</span> <span class="n">front</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">([[[1]], [[1, 2]]], 2)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_eject">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_eject</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">front</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1595-L1628"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_eject" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert <code class="docutils literal notranslate"><span class="pre">f</span></code> from <code class="docutils literal notranslate"><span class="pre">K[X,Y]</span></code> to <code class="docutils literal notranslate"><span class="pre">K[X][Y]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_eject</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_eject</span><span class="p">([[[</span><span class="mi">1</span><span class="p">]],</span> <span class="p">[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">]]],</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">[</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">])</span>
<span class="go">[1, x + 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_terms_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_terms_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1661-L1691"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_terms_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove GCD of terms from <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_terms_gcd</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_terms_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">((2, 1), [[1], [1, 0]])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_list_terms">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_list_terms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1713-L1742"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_list_terms" title="Permalink to this definition">¶</a></dt>
<dd><p>List all non-zero terms from <code class="docutils literal notranslate"><span class="pre">f</span></code> in the given order <code class="docutils literal notranslate"><span class="pre">order</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_list_terms</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_list_terms</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[((1, 1), 1), ((1, 0), 1), ((0, 1), 2), ((0, 0), 3)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_list_terms</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;grevlex&#39;</span><span class="p">)</span>
<span class="go">[((1, 1), 1), ((1, 0), 1), ((0, 1), 2), ((0, 0), 3)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_apply_pairs">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_apply_pairs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1777-L1809"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_apply_pairs" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply <code class="docutils literal notranslate"><span class="pre">h</span></code> to pairs of coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dmp_apply_pairs</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">:</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">-</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dmp_apply_pairs</span><span class="p">([[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]],</span> <span class="p">[[</span><span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]],</span> <span class="n">h</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[4], [5, 6]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dmp_slice">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dmp_slice</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1833-L1835"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dmp_slice" title="Permalink to this definition">¶</a></dt>
<dd><p>Take a continuous subsequence of terms of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densebasic.dup_random">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densebasic.</span></span><span class="sig-name descname"><span class="pre">dup_random</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densebasic.py#L1862-L1881"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densebasic.dup_random" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a polynomial of degree <code class="docutils literal notranslate"><span class="pre">n</span></code> with coefficients in <code class="docutils literal notranslate"><span class="pre">[a,</span> <span class="pre">b]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.densebasic</span> <span class="kn">import</span> <span class="n">dup_random</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dup_random</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> 
<span class="go">[-2, -8, 9, -4]</span>
</pre></div>
</div>
</dd></dl>

<p><strong>Arithmetic operations:</strong></p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_add_term">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_add_term</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L43-L74"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_add_term" title="Permalink to this definition">¶</a></dt>
<dd><p>Add <code class="docutils literal notranslate"><span class="pre">c(x_2..x_u)*x_0**i</span></code> to <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_add_term</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">2*x**2 + x*y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_sub_term">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_sub_term</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L106-L137"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_sub_term" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract <code class="docutils literal notranslate"><span class="pre">c(x_2..x_u)*x_0**i</span></code> from <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_sub_term</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x*y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_mul_term">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_mul_term</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">i</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L160-L184"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_mul_term" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">c(x_2..x_u)*x_0**i</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_mul_term</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">3*x**4*y**2 + 3*x**3*y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_add_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_add_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L204-L218"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_add_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an element of the ground domain to <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_add_ground</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">))</span>
<span class="go">x**3 + 2*x**2 + 3*x + 8</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_sub_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_sub_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L238-L252"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_sub_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract an element of the ground domain from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_sub_ground</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">))</span>
<span class="go">x**3 + 2*x**2 + 3*x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_mul_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_mul_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L275-L294"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_mul_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply <code class="docutils literal notranslate"><span class="pre">f</span></code> by a constant value in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_mul_ground</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
<span class="go">6*x + 6*y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_quo_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_quo_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L326-L349"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_quo_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Quotient by a constant in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_quo_ground</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">x**2*y + x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_quo_ground</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">x**2*y + 3/2*x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_exquo_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_exquo_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L374-L393"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_exquo_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Exact quotient by a constant in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_exquo_ground</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">1/2*x**2*y + x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dup_lshift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dup_lshift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L396-L413"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dup_lshift" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently multiply <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">x**n</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_lshift</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**4 + x**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dup_rshift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dup_rshift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L416-L432"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dup_rshift" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently divide <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">x**n</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_rshift</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_rshift</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_abs">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_abs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L452-L471"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_abs" title="Permalink to this definition">¶</a></dt>
<dd><p>Make all coefficients positive in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_abs</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2*y + x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_neg">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_neg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L491-L510"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_neg" title="Permalink to this definition">¶</a></dt>
<dd><p>Negate a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_neg</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span>
<span class="go">-x**2*y + x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_add">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L548-L587"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add dense polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_add</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2*y + x**2 + x + y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_sub">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L625-L664"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_sub" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract dense polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_sub</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
<span class="go">-x**2*y + x**2 - x + y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_add_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_add_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L684-L698"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_add_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">+</span> <span class="pre">g*h</span></code> where <code class="docutils literal notranslate"><span class="pre">f,</span> <span class="pre">g,</span> <span class="pre">h</span></code> are in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_add_mul</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">2*x**2 + 2*x + y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_sub_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_sub_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L718-L732"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_sub_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">-</span> <span class="pre">g*h</span></code> where <code class="docutils literal notranslate"><span class="pre">f,</span> <span class="pre">g,</span> <span class="pre">h</span></code> are in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_sub_mul</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-2*x + y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L792-L832"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply dense polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_mul</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">x**2*y + x</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_sqr">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_sqr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L875-L920"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_sqr" title="Permalink to this definition">¶</a></dt>
<dd><p>Square dense polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_sqr</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">x**4 + 2*x**3*y + 3*x**2*y**2 + 2*x*y**3 + y**4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_pow">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_pow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L960-L997"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_pow" title="Permalink to this definition">¶</a></dt>
<dd><p>Raise <code class="docutils literal notranslate"><span class="pre">f</span></code> to the <code class="docutils literal notranslate"><span class="pre">n</span></code>-th power in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pow</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">x**3*y**3 + 3*x**2*y**2 + 3*x*y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_pdiv">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_pdiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1145-L1199"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_pdiv" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-division in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pdiv</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(2*x + 2*y - 2, -4*y + 4)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_prem">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_prem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1202-L1250"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_prem" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-remainder in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_prem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-4*y + 4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_pquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_pquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1253-L1274"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_pquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial exact pseudo-quotient in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">2*x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="go">2*x + 2*y - 2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_pexquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_pexquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1277-L1305"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_pexquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial pseudo-quotient in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pexquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">2*x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_pexquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">[[2], [2]] does not divide [[1], [1, 0], []]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_rr_div">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_rr_div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1357-L1407"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_rr_div" title="Permalink to this definition">¶</a></dt>
<dd><p>Multivariate division with remainder over a ring.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_rr_div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(0, x**2 + x*y)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_ff_div">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_ff_div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1462-L1512"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_ff_div" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial division with remainder over a field.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ff_div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(1/2*x + 1/2*y - 1/2, -y + 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_div">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1608-L1629"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_div" title="Permalink to this definition">¶</a></dt>
<dd><p>Polynomial division with remainder in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(0, x**2 + x*y)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_div</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(1/2*x + 1/2*y - 1/2, -y + 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_rem">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_rem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1632-L1650"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_rem" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns polynomial remainder in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_rem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 + x*y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_rem</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_quo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_quo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1653-L1671"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_quo" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns exact polynomial quotient in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_quo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">0</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_quo</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">1/2*x + 1/2*y - 1/2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_exquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_exquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1674-L1702"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_exquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns polynomial quotient in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_exquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_exquo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">[[2], [2]] does not divide [[1], [1, 0], []]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_max_norm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_max_norm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1725-L1744"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_max_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns maximum norm of a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_max_norm</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_l1_norm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_l1_norm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1767-L1786"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_l1_norm" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns l1 norm of a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_l1_norm</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densearith.dmp_expand">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densearith.</span></span><span class="sig-name descname"><span class="pre">dmp_expand</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">polys</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densearith.py#L1814-L1836"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densearith.dmp_expand" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply together several polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_expand</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
<span class="go">x**3 + x**2 + x*y**2 + y**2</span>
</pre></div>
</div>
</dd></dl>

<p><strong>Further tools:</strong></p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_integrate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_integrate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L71-L103"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_integrate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the indefinite integral of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">x_0</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_integrate</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">1/2*x**2 + 2*x*y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_integrate</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">1/6*x**3 + x**2*y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_integrate_in">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_integrate_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L116-L135"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_integrate_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the indefinite integral of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">x_j</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_integrate_in</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">1/2*x**2 + 2*x*y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_integrate_in</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x*y + y**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_diff">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_diff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L181-L225"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_diff" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">m</span></code>-th order derivative in <code class="docutils literal notranslate"><span class="pre">x_0</span></code> of a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">y**2 + 2*y + 3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_diff_in">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_diff_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L238-L259"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_diff_in" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">m</span></code>-th order derivative in <code class="docutils literal notranslate"><span class="pre">x_j</span></code> of a polynomial in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">y**2 + 2*y + 3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">2*x*y + 2*x + 4*y + 3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_eval">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L288-L314"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate a polynomial at <code class="docutils literal notranslate"><span class="pre">x_0</span> <span class="pre">=</span> <span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> using the Horner scheme.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_eval</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">5*y + 8</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_eval_in">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_eval_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L327-L348"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_eval_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate a polynomial at <code class="docutils literal notranslate"><span class="pre">x_j</span> <span class="pre">=</span> <span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> using the Horner scheme.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_eval_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">5*y + 8</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_eval_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">7*x + 4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_eval_tail">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_eval_tail</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L364-L393"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_eval_tail" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate a polynomial at <code class="docutils literal notranslate"><span class="pre">x_j</span> <span class="pre">=</span> <span class="pre">a_j,</span> <span class="pre">...</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_eval_tail</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">])</span>
<span class="go">7*x + 4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_eval_tail</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>
<span class="go">18</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_diff_eval_in">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_diff_eval_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L406-L429"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_diff_eval_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Differentiate and evaluate a polynomial in <code class="docutils literal notranslate"><span class="pre">x_j</span></code> at <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff_eval_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">y**2 + 2*y + 3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_diff_eval_in</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">6*x + 11</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_trunc">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L462-L479"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_trunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce a <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> polynomial modulo a polynomial <code class="docutils literal notranslate"><span class="pre">p</span></code> in <code class="docutils literal notranslate"><span class="pre">K[Y]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_trunc</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">11*x**2 + 11*x + 5</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_ground_trunc">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L482-L503"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_ground_trunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce a <code class="docutils literal notranslate"><span class="pre">K[X]</span></code> polynomial modulo a constant <code class="docutils literal notranslate"><span class="pre">p</span></code> in <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_trunc</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
<span class="go">-x**2 - x*y - y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_monic">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_monic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L506-L532"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Divide all coefficients by <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_monic</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">9</span><span class="p">)</span>
<span class="go">x**2 + 2*x + 3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_monic</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">x**2 + 4/3*x + 2/3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_ground_monic">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_monic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L535-L568"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_ground_monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Divide all coefficients by <code class="docutils literal notranslate"><span class="pre">LC(f)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">9</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_monic</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">x**2*y + 2*x**2 + x*y + 3*y + 1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_monic</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">x**2*y + 8/3*x**2 + 5/3*x*y + 2*x + 2/3*y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_content">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L571-L610"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_content" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the GCD of coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_ground_content">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L613-L655"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_ground_content" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the GCD of coefficients of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_primitive">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_primitive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L658-L688"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute content and the primitive form of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_primitive</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">(2, 3*x**2 + 4*x + 6)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_primitive</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">(2, 3*x**2 + 4*x + 6)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_ground_primitive">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_primitive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L691-L724"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_ground_primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute content and the primitive form of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_primitive</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">(2, x*y + 3*x + 2*y + 6)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_primitive</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">(2, x*y + 3*x + 2*y + 6)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_extract">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_extract</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L727-L750"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_extract" title="Permalink to this definition">¶</a></dt>
<dd><p>Extract common content from a pair of polynomials in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_extract</span><span class="p">(</span><span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">(2, 3*x**2 + 6*x + 9, 2*x**2 + 4*x + 6)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_ground_extract">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_ground_extract</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L753-L776"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_ground_extract" title="Permalink to this definition">¶</a></dt>
<dd><p>Extract common content from a pair of polynomials in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ground_extract</span><span class="p">(</span><span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">(2, 3*x*y + 6*x + 9, 2*x*y + 4*x + 6)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_real_imag">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_real_imag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L779-L823"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_real_imag" title="Permalink to this definition">¶</a></dt>
<dd><p>Return bivariate polynomials <code class="docutils literal notranslate"><span class="pre">f1</span></code> and <code class="docutils literal notranslate"><span class="pre">f2</span></code>, such that <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">f1</span> <span class="pre">+</span> <span class="pre">f2*I</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_real_imag</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">(x**3 + x**2 - 3*x*y**2 + x - y**2 + 1, 3*x**2*y + 2*x*y - y**3 + y)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_mirror">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_mirror</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L826-L845"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_mirror" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate efficiently the composition <code class="docutils literal notranslate"><span class="pre">f(-x)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_mirror</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-x**3 + 2*x**2 + 4*x + 2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_scale">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_scale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L848-L867"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_scale" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate efficiently composition <code class="docutils literal notranslate"><span class="pre">f(a*x)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_scale</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">4*x**2 - 4*x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_shift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_shift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L870-L890"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_shift" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate efficiently Taylor shift <code class="docutils literal notranslate"><span class="pre">f(x</span> <span class="pre">+</span> <span class="pre">a)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_shift</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="go">x**2 + 2*x + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_transform">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_transform</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">q</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L893-L921"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate functional transformation <code class="docutils literal notranslate"><span class="pre">q**n</span> <span class="pre">*</span> <span class="pre">f(p/q)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_transform</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">x**4 - 2*x**3 + 5*x**2 - 4*x + 4</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_compose">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_compose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L953-L979"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate functional composition <code class="docutils literal notranslate"><span class="pre">f(g)</span></code> in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_compose</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">y**2 + 3*y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_decompose">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_decompose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L1045-L1092"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_decompose" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes functional decomposition of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p>Given a univariate polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> with coefficients in a field of
characteristic zero, returns list <code class="docutils literal notranslate"><span class="pre">[f_1,</span> <span class="pre">f_2,</span> <span class="pre">...,</span> <span class="pre">f_n]</span></code>, where:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">f_1</span> <span class="n">o</span> <span class="n">f_2</span> <span class="n">o</span> <span class="o">...</span> <span class="n">f_n</span> <span class="o">=</span> <span class="n">f_1</span><span class="p">(</span><span class="n">f_2</span><span class="p">(</span><span class="o">...</span> <span class="n">f_n</span><span class="p">))</span>
</pre></div>
</div>
<p>and <code class="docutils literal notranslate"><span class="pre">f_2,</span> <span class="pre">...,</span> <span class="pre">f_n</span></code> are monic and homogeneous polynomials of at
least second degree.</p>
<p>Unlike factorization, complete functional decompositions of
polynomials are not unique, consider examples:</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">o</span> <span class="pre">g</span> <span class="pre">=</span> <span class="pre">f(x</span> <span class="pre">+</span> <span class="pre">b)</span> <span class="pre">o</span> <span class="pre">(g</span> <span class="pre">-</span> <span class="pre">b)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">x**n</span> <span class="pre">o</span> <span class="pre">x**m</span> <span class="pre">=</span> <span class="pre">x**m</span> <span class="pre">o</span> <span class="pre">x**n</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">T_n</span> <span class="pre">o</span> <span class="pre">T_m</span> <span class="pre">=</span> <span class="pre">T_m</span> <span class="pre">o</span> <span class="pre">T_n</span></code></p></li>
</ol>
<p>where <code class="docutils literal notranslate"><span class="pre">T_n</span></code> and <code class="docutils literal notranslate"><span class="pre">T_m</span></code> are Chebyshev polynomials.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_decompose</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[x**2, x**2 - x]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r645"><span class="brackets"><a class="fn-backref" href="#id2">R645</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#kozen89" id="id1"><span>[Kozen89]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_lift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_lift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L1095-L1140"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_lift" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert algebraic coefficients to integers in <code class="docutils literal notranslate"><span class="pre">K[X]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">I</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">K</span> <span class="o">=</span> <span class="n">QQ</span><span class="o">.</span><span class="n">algebraic_field</span><span class="p">(</span><span class="n">I</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">K</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">K</span><span class="p">([</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)])</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">K</span><span class="p">([</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_lift</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">x**8 + 2*x**6 + 9*x**4 - 8*x**2 + 16</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dup_sign_variations">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dup_sign_variations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L1143-L1166"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dup_sign_variations" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the number of sign variations of <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">K[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_sign_variations</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_clear_denoms">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_clear_denoms</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K1</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">convert</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L1223-L1258"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_clear_denoms" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear denominators, i.e. transform <code class="docutils literal notranslate"><span class="pre">K_0</span></code> to <code class="docutils literal notranslate"><span class="pre">K_1</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_clear_denoms</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">convert</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">(6, 3*x + 2*y + 6)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_clear_denoms</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">convert</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">(6, 3*x + 2*y + 6)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.densetools.dmp_revert">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.densetools.</span></span><span class="sig-name descname"><span class="pre">dmp_revert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/densetools.py#L1295-L1309"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.densetools.dmp_revert" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f**(-1)</span></code> mod <code class="docutils literal notranslate"><span class="pre">x**n</span></code> using Newton iteration.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="manipulation-of-dense-univariate-polynomials-with-finite-field-coefficients">
<h3>Manipulation of dense, univariate polynomials with finite field coefficients<a class="headerlink" href="#manipulation-of-dense-univariate-polynomials-with-finite-field-coefficients" title="Permalink to this headline">¶</a></h3>
<p>Functions in this module carry the prefix <code class="docutils literal notranslate"><span class="pre">gf_</span></code>, referring to the classical
name “Galois Fields” for finite fields. Note that many polynomial
factorization algorithms work by reduction to the finite field case, so having
special implementations for this case is justified both by performance, and by
the necessity of certain methods which do not even make sense over general
fields.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_crt">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_crt</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">U</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L15-L57"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_crt" title="Permalink to this definition">¶</a></dt>
<dd><p>Chinese Remainder Theorem.</p>
<p>Given a set of integer residues <code class="docutils literal notranslate"><span class="pre">u_0,...,u_n</span></code> and a set of
co-prime integer moduli <code class="docutils literal notranslate"><span class="pre">m_0,...,m_n</span></code>, returns an integer
<code class="docutils literal notranslate"><span class="pre">u</span></code>, such that <code class="docutils literal notranslate"><span class="pre">u</span> <span class="pre">=</span> <span class="pre">u_i</span> <span class="pre">mod</span> <span class="pre">m_i</span></code> for <code class="docutils literal notranslate"><span class="pre">i</span> <span class="pre">=</span> <span class="pre">``0,...,n</span></code>.</p>
<p class="rubric">Examples</p>
<p>Consider a set of residues <code class="docutils literal notranslate"><span class="pre">U</span> <span class="pre">=</span> <span class="pre">[49,</span> <span class="pre">76,</span> <span class="pre">65]</span></code>
and a set of moduli <code class="docutils literal notranslate"><span class="pre">M</span> <span class="pre">=</span> <span class="pre">[99,</span> <span class="pre">97,</span> <span class="pre">95]</span></code>. Then we have:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_crt</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_crt</span><span class="p">([</span><span class="mi">49</span><span class="p">,</span> <span class="mi">76</span><span class="p">,</span> <span class="mi">65</span><span class="p">],</span> <span class="p">[</span><span class="mi">99</span><span class="p">,</span> <span class="mi">97</span><span class="p">,</span> <span class="mi">95</span><span class="p">],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">639985</span>
</pre></div>
</div>
<p>This is the correct result because:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="mi">639985</span> <span class="o">%</span> <span class="n">m</span> <span class="k">for</span> <span class="n">m</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">99</span><span class="p">,</span> <span class="mi">97</span><span class="p">,</span> <span class="mi">95</span><span class="p">]]</span>
<span class="go">[49, 76, 65]</span>
</pre></div>
</div>
<p>Note: this is a low-level routine with no error checking.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="../ntheory.html#sympy.ntheory.modular.crt" title="sympy.ntheory.modular.crt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.ntheory.modular.crt</span></code></a></dt><dd><p>a higher level crt routine</p>
</dd>
</dl>
<p><a class="reference internal" href="../ntheory.html#sympy.ntheory.modular.solve_congruence" title="sympy.ntheory.modular.solve_congruence"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.ntheory.modular.solve_congruence</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_crt1">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_crt1</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L60-L81"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_crt1" title="Permalink to this definition">¶</a></dt>
<dd><p>First part of the Chinese Remainder Theorem.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_crt1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_crt1</span><span class="p">([</span><span class="mi">99</span><span class="p">,</span> <span class="mi">97</span><span class="p">,</span> <span class="mi">95</span><span class="p">],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">(912285, [9215, 9405, 9603], [62, 24, 12])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_crt2">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_crt2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">U</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">E</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">S</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L84-L109"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_crt2" title="Permalink to this definition">¶</a></dt>
<dd><p>Second part of the Chinese Remainder Theorem.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_crt2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">U</span> <span class="o">=</span> <span class="p">[</span><span class="mi">49</span><span class="p">,</span> <span class="mi">76</span><span class="p">,</span> <span class="mi">65</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">M</span> <span class="o">=</span> <span class="p">[</span><span class="mi">99</span><span class="p">,</span> <span class="mi">97</span><span class="p">,</span> <span class="mi">95</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="mi">912285</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">E</span> <span class="o">=</span> <span class="p">[</span><span class="mi">9215</span><span class="p">,</span> <span class="mi">9405</span><span class="p">,</span> <span class="mi">9603</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span> <span class="o">=</span> <span class="p">[</span><span class="mi">62</span><span class="p">,</span> <span class="mi">24</span><span class="p">,</span> <span class="mi">12</span><span class="p">]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_crt2</span><span class="p">(</span><span class="n">U</span><span class="p">,</span> <span class="n">M</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">E</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">639985</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_int">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_int</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L112-L130"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_int" title="Permalink to this definition">¶</a></dt>
<dd><p>Coerce <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">mod</span> <span class="pre">p</span></code> to an integer in the range <code class="docutils literal notranslate"><span class="pre">[-p/2,</span> <span class="pre">p/2]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_int</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_int</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_int</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="go">-2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_degree">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_degree</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L133-L148"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_degree" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading degree of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_degree</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_degree</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_degree</span><span class="p">([])</span>
<span class="go">-1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_LC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L151-L168"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_LC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_LC</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_TC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_TC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L171-L188"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_TC" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the trailing coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_TC</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_TC</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_strip">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_strip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L191-L216"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_strip" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove leading zeros from <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_strip</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_strip</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
<span class="go">[3, 0, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_trunc">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_trunc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L219-L232"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_trunc" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce all coefficients modulo <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_trunc</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_trunc</span><span class="p">([</span><span class="mi">7</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">[2, 3, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_normal">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_normal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L235-L249"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize all coefficients in <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_normal</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_normal</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_from_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_from_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L252-L277"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial from a dict.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_from_dict</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_from_dict</span><span class="p">({</span><span class="mi">10</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="mi">4</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">33</span><span class="p">),</span> <span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)},</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_to_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_to_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symmetric</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L280-L306"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_to_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial to a dict.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_to_dict</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_to_dict</span><span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">{0: -1, 4: -2, 10: -1}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_to_dict</span><span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">symmetric</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">{0: 4, 4: 3, 10: 4}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_from_int_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_from_int_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L309-L322"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_from_int_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial from <code class="docutils literal notranslate"><span class="pre">Z[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_from_int_poly</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_from_int_poly</span><span class="p">([</span><span class="mi">7</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">[2, 3, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_to_int_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_to_int_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symmetric</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L325-L344"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_to_int_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial to <code class="docutils literal notranslate"><span class="pre">Z[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_to_int_poly</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_to_int_poly</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">[2, -2, -2]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_to_int_poly</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">symmetric</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">[2, 3, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_neg">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_neg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L347-L361"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_neg" title="Permalink to this definition">¶</a></dt>
<dd><p>Negate a polynomial in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_neg</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_neg</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[2, 3, 4, 0]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_add_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_add_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L364-L389"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_add_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">+</span> <span class="pre">a</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_add_ground</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_add_ground</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 2, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sub_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sub_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L392-L417"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sub_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">-</span> <span class="pre">a</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sub_ground</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sub_ground</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 2, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_mul_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_mul_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L420-L437"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_mul_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">*</span> <span class="pre">a</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_mul_ground</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_mul_ground</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 4, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_quo_ground">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_quo_ground</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L440-L454"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_quo_ground" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f/a</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> and <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_quo_ground</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_quo_ground</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 1, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_add">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L457-L489"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add polynomials in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_add</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_add</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sub">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L492-L524"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sub" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtract polynomials in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sub</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sub</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 0, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L527-L555"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply polynomials in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_mul</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_mul</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 0, 3, 2, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sqr">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sqr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L558-L598"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sqr" title="Permalink to this definition">¶</a></dt>
<dd><p>Square polynomials in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sqr</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sqr</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 2, 3, 1, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_add_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_add_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L601-L613"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_add_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">+</span> <span class="pre">g*h</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">g</span></code>, <code class="docutils literal notranslate"><span class="pre">h</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_add_mul</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_add_mul</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[2, 3, 2, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sub_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sub_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L616-L630"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sub_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">-</span> <span class="pre">g*h</span></code> where <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">g</span></code>, <code class="docutils literal notranslate"><span class="pre">h</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sub_mul</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sub_mul</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 3, 2, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_expand">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_expand</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L633-L658"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_expand" title="Permalink to this definition">¶</a></dt>
<dd><p>Expand results of <a class="reference internal" href="reference.html#sympy.polys.polytools.factor" title="sympy.polys.polytools.factor"><code class="xref py py-func docutils literal notranslate"><span class="pre">factor()</span></code></a> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_expand</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_expand</span><span class="p">([([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">1</span><span class="p">),</span> <span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">2</span><span class="p">),</span> <span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">)],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 3, 0, 3, 0, 1, 4, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_div">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_div</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L661-L712"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_div" title="Permalink to this definition">¶</a></dt>
<dd><p>Division with remainder in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p>Given univariate polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> with coefficients in a
finite field with <code class="docutils literal notranslate"><span class="pre">p</span></code> elements, returns polynomials <code class="docutils literal notranslate"><span class="pre">q</span></code> and <code class="docutils literal notranslate"><span class="pre">r</span></code>
(quotient and remainder) such that <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">q*g</span> <span class="pre">+</span> <span class="pre">r</span></code>.</p>
<p>Consider polynomials <code class="docutils literal notranslate"><span class="pre">x**3</span> <span class="pre">+</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">x**2</span> <span class="pre">+</span> <span class="pre">x</span></code> in GF(2):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_div</span><span class="p">,</span> <span class="n">gf_add_mul</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_div</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">([1, 1], [1])</span>
</pre></div>
</div>
<p>As result we obtained quotient <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">+</span> <span class="pre">1</span></code> and remainder <code class="docutils literal notranslate"><span class="pre">1</span></code>, thus:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_add_mul</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 0, 1, 1]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r646"><span class="brackets"><a class="fn-backref" href="#id5">R646</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#monagan93" id="id3"><span>[Monagan93]</span></a></p>
</dd>
<dt class="label" id="r647"><span class="brackets"><a class="fn-backref" href="#id6">R647</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id4"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_rem">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_rem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L715-L729"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_rem" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial remainder in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_rem</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_rem</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_quo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_quo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L732-L768"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_quo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute exact quotient in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_quo</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_quo</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 1]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_quo</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 2, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_exquo">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_exquo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L771-L795"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_exquo" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial quotient in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_exquo</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_exquo</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 2, 4]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_exquo</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="mi">2</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="gr">ExactQuotientFailed</span>: <span class="n">[1, 1, 0] does not divide [1, 0, 1, 1]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_lshift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_lshift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L798-L815"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_lshift" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently multiply <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">x**n</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_lshift</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_lshift</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">4</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[3, 2, 4, 0, 0, 0, 0]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_rshift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_rshift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L818-L835"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_rshift" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently divide <code class="docutils literal notranslate"><span class="pre">f</span></code> by <code class="docutils literal notranslate"><span class="pre">x**n</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_rshift</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_rshift</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="mi">3</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">([1, 2], [3, 4, 0])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_pow">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_pow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L838-L873"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_pow" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f**n</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> using repeated squaring.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_pow</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_pow</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[2, 4, 4, 2, 2, 1, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_pow_mod">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_pow_mod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L961-L1007"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_pow_mod" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute <code class="docutils literal notranslate"><span class="pre">f**n</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]/(g)</span></code> using repeated squaring.</p>
<p>Given polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> and a non-negative
integer <code class="docutils literal notranslate"><span class="pre">n</span></code>, efficiently computes <code class="docutils literal notranslate"><span class="pre">f**n</span> <span class="pre">(mod</span> <span class="pre">g)</span></code> i.e. the remainder
of <code class="docutils literal notranslate"><span class="pre">f**n</span></code> from division by <code class="docutils literal notranslate"><span class="pre">g</span></code>, using the repeated squaring algorithm.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_pow_mod</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_pow_mod</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">3</span><span class="p">,</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r648"><span class="brackets"><a class="fn-backref" href="#id8">R648</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id7"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1010-L1027"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Euclidean Algorithm in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_gcd</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_gcd</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_lcm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_lcm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1030-L1050"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_lcm" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial LCM in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_lcm</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_lcm</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 2, 0, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_cofactors">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_cofactors</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1053-L1073"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_cofactors" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial GCD and cofactors in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_cofactors</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_cofactors</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">([1, 3], [3, 3], [2, 1])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_gcdex">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1076-L1139"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Extended Euclidean Algorithm in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p>Given polynomials <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>, computes polynomials
<code class="docutils literal notranslate"><span class="pre">s</span></code>, <code class="docutils literal notranslate"><span class="pre">t</span></code> and <code class="docutils literal notranslate"><span class="pre">h</span></code>, such that <code class="docutils literal notranslate"><span class="pre">h</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code> and <code class="docutils literal notranslate"><span class="pre">s*f</span> <span class="pre">+</span> <span class="pre">t*g</span> <span class="pre">=</span> <span class="pre">h</span></code>.
The typical application of EEA is solving polynomial diophantine equations.</p>
<p>Consider polynomials <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">7)</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">1)</span></code>, <code class="docutils literal notranslate"><span class="pre">g</span> <span class="pre">=</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">7)</span> <span class="pre">(x**2</span> <span class="pre">+</span> <span class="pre">1)</span></code>
in <code class="docutils literal notranslate"><span class="pre">GF(11)[x]</span></code>. Application of Extended Euclidean Algorithm gives:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_gcdex</span><span class="p">,</span> <span class="n">gf_mul</span><span class="p">,</span> <span class="n">gf_add</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">g</span> <span class="o">=</span> <span class="n">gf_gcdex</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">]),</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">g</span>
<span class="go">([5, 6], [6], [1, 7])</span>
</pre></div>
</div>
<p>As result we obtained polynomials <code class="docutils literal notranslate"><span class="pre">s</span> <span class="pre">=</span> <span class="pre">5*x</span> <span class="pre">+</span> <span class="pre">6</span></code> and <code class="docutils literal notranslate"><span class="pre">t</span> <span class="pre">=</span> <span class="pre">6</span></code>, and
additionally <code class="docutils literal notranslate"><span class="pre">gcd(f,</span> <span class="pre">g)</span> <span class="pre">=</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">7</span></code>. This is correct because:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">S</span> <span class="o">=</span> <span class="n">gf_mul</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">]),</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">T</span> <span class="o">=</span> <span class="n">gf_mul</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">]),</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_add</span><span class="p">(</span><span class="n">S</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> <span class="o">==</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">]</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r649"><span class="brackets"><a class="fn-backref" href="#id10">R649</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id9"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_monic">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_monic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1142-L1164"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_monic" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute LC and a monic polynomial in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_monic</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_monic</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">(3, [1, 4, 3])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_diff">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_diff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1167-L1194"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_diff" title="Permalink to this definition">¶</a></dt>
<dd><p>Differentiate polynomial in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_diff</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_diff</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_eval">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1197-L1218"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate <code class="docutils literal notranslate"><span class="pre">f(a)</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)</span></code> using Horner scheme.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_eval</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_eval</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">0</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_multi_eval">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_multi_eval</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1221-L1235"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_multi_eval" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate <code class="docutils literal notranslate"><span class="pre">f(a)</span></code> for <code class="docutils literal notranslate"><span class="pre">a</span></code> in <code class="docutils literal notranslate"><span class="pre">[a_1,</span> <span class="pre">...,</span> <span class="pre">a_n]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_multi_eval</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_multi_eval</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4, 4, 0, 2, 0]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_compose">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_compose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1238-L1264"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial composition <code class="docutils literal notranslate"><span class="pre">f(g)</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_compose</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_compose</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[2, 4, 0, 3, 0]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_compose_mod">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_compose_mod</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1267-L1291"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_compose_mod" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial composition <code class="docutils literal notranslate"><span class="pre">g(h)</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]/(f)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_compose_mod</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_compose_mod</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span> <span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_trace_map">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_trace_map</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1294-L1347"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_trace_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute polynomial trace map in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]/(f)</span></code>.</p>
<p>Given a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>, polynomials <code class="docutils literal notranslate"><span class="pre">a</span></code>, <code class="docutils literal notranslate"><span class="pre">b</span></code>,
<code class="docutils literal notranslate"><span class="pre">c</span></code> in the quotient ring <code class="docutils literal notranslate"><span class="pre">GF(p)[x]/(f)</span></code> such that <code class="docutils literal notranslate"><span class="pre">b</span> <span class="pre">=</span> <span class="pre">c**t</span>
<span class="pre">(mod</span> <span class="pre">f)</span></code> for some positive power <code class="docutils literal notranslate"><span class="pre">t</span></code> of <code class="docutils literal notranslate"><span class="pre">p</span></code>, and a positive
integer <code class="docutils literal notranslate"><span class="pre">n</span></code>, returns a mapping:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">-&gt;</span> <span class="n">a</span><span class="o">**</span><span class="n">t</span><span class="o">**</span><span class="n">n</span><span class="p">,</span> <span class="n">a</span> <span class="o">+</span> <span class="n">a</span><span class="o">**</span><span class="n">t</span> <span class="o">+</span> <span class="n">a</span><span class="o">**</span><span class="n">t</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="o">...</span> <span class="o">+</span> <span class="n">a</span><span class="o">**</span><span class="n">t</span><span class="o">**</span><span class="n">n</span> <span class="p">(</span><span class="n">mod</span> <span class="n">f</span><span class="p">)</span>
</pre></div>
</div>
<p>In factorization context, <code class="docutils literal notranslate"><span class="pre">b</span> <span class="pre">=</span> <span class="pre">x**p</span> <span class="pre">mod</span> <span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">=</span> <span class="pre">x</span> <span class="pre">mod</span> <span class="pre">f</span></code>.
This way we can efficiently compute trace polynomials in equal
degree factorization routine, much faster than with other methods,
like iterated Frobenius algorithm, for large degrees.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_trace_map</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_trace_map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">4</span><span class="p">,</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">([1, 3], [1, 3])</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r650"><span class="brackets"><a class="fn-backref" href="#id12">R650</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen92" id="id11"><span>[Gathen92]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_random">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_random</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1363-L1376"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_random" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate a random polynomial in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> of degree <code class="docutils literal notranslate"><span class="pre">n</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_random</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_random</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> 
<span class="go">[1, 2, 3, 2, 1, 1, 1, 2, 0, 4, 2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_irreducible">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_irreducible</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1379-L1395"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_irreducible" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate random irreducible polynomial of degree <code class="docutils literal notranslate"><span class="pre">n</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_irreducible</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_irreducible</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> 
<span class="go">[1, 4, 2, 2, 3, 2, 4, 1, 4, 0, 4]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_irreducible_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_irreducible_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1490-L1513"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_irreducible_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Test irreducibility of a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_irreducible_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_irreducible_p</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_irreducible_p</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sqf_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sqf_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1516-L1537"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sqf_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is square-free in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sqf_p</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sqf_p</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sqf_p</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sqf_part">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sqf_part</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1540-L1561"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sqf_part" title="Permalink to this definition">¶</a></dt>
<dd><p>Return square-free part of a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_sqf_part</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sqf_part</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[1, 4, 3]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_sqf_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_sqf_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">all</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1564-L1650"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_sqf_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the square-free decomposition of a <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> polynomial.</p>
<p>Given a polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>, returns the leading coefficient
of <code class="docutils literal notranslate"><span class="pre">f</span></code> and a square-free decomposition <code class="docutils literal notranslate"><span class="pre">f_1**e_1</span> <span class="pre">f_2**e_2</span> <span class="pre">...</span> <span class="pre">f_k**e_k</span></code>
such that all <code class="docutils literal notranslate"><span class="pre">f_i</span></code> are monic polynomials and <code class="docutils literal notranslate"><span class="pre">(f_i,</span> <span class="pre">f_j)</span></code> for <code class="docutils literal notranslate"><span class="pre">i</span> <span class="pre">!=</span> <span class="pre">j</span></code>
are co-prime and <code class="docutils literal notranslate"><span class="pre">e_1</span> <span class="pre">...</span> <span class="pre">e_k</span></code> are given in increasing order. All trivial
terms (i.e. <code class="docutils literal notranslate"><span class="pre">f_i</span> <span class="pre">=</span> <span class="pre">1</span></code>) aren’t included in the output.</p>
<p>Consider polynomial <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">x**11</span> <span class="pre">+</span> <span class="pre">1</span></code> over <code class="docutils literal notranslate"><span class="pre">GF(11)[x]</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>

<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="p">(</span>
<span class="gp">... </span>    <span class="n">gf_from_dict</span><span class="p">,</span> <span class="n">gf_diff</span><span class="p">,</span> <span class="n">gf_sqf_list</span><span class="p">,</span> <span class="n">gf_pow</span><span class="p">,</span>
<span class="gp">... </span><span class="p">)</span>
<span class="gp">... </span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">gf_from_dict</span><span class="p">({</span><span class="mi">11</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)},</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">f'(x)</span> <span class="pre">=</span> <span class="pre">0</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_diff</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
<p>This phenomenon doesn’t happen in characteristic zero. However we can
still compute square-free decomposition of <code class="docutils literal notranslate"><span class="pre">f</span></code> using <code class="docutils literal notranslate"><span class="pre">gf_sqf()</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_sqf_list</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">(1, [([1, 1], 11)])</span>
</pre></div>
</div>
<p>We obtained factorization <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">1)**11</span></code>. This is correct because:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_pow</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r651"><span class="brackets"><a class="fn-backref" href="#id14">R651</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#geddes92" id="id13"><span>[Geddes92]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_Qmatrix">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_Qmatrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1653-L1690"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_Qmatrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculate Berlekamp’s <code class="docutils literal notranslate"><span class="pre">Q</span></code> matrix.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_Qmatrix</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_Qmatrix</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0],</span>
<span class="go"> [3, 4]]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_Qmatrix</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0, 0, 0],</span>
<span class="go"> [0, 4, 0, 0],</span>
<span class="go"> [0, 0, 1, 0],</span>
<span class="go"> [0, 0, 0, 4]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_Qbasis">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_Qbasis</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">Q</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1693-L1752"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_Qbasis" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a basis of the kernel of <code class="docutils literal notranslate"><span class="pre">Q</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_Qmatrix</span><span class="p">,</span> <span class="n">gf_Qbasis</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_Qbasis</span><span class="p">(</span><span class="n">gf_Qmatrix</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0, 0, 0], [0, 0, 1, 0]]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_Qbasis</span><span class="p">(</span><span class="n">gf_Qmatrix</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_berlekamp">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_berlekamp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L1755-L1796"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_berlekamp" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor a square-free <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> for small <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_berlekamp</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_berlekamp</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 0, 2], [1, 0, 3]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_zassenhaus">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_zassenhaus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2051-L2070"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_zassenhaus" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor a square-free <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> for medium <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_zassenhaus</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_zassenhaus</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 1], [1, 3]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_shoup">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_shoup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2073-L2092"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_shoup" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor a square-free <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code> for large <code class="docutils literal notranslate"><span class="pre">p</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_shoup</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_shoup</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">[[1, 1], [1, 3]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_factor_sqf">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_factor_sqf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2101-L2127"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_factor_sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor a square-free polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_factor_sqf</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_factor_sqf</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]),</span> <span class="mi">5</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">(3, [[1, 1], [1, 3]])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2130-L2191"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor (non square-free) polynomials in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>.</p>
<p>Given a possibly non square-free polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> in <code class="docutils literal notranslate"><span class="pre">GF(p)[x]</span></code>,
returns its complete factorization into irreducibles:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f_1</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="n">e_1</span> <span class="n">f_2</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="n">e_2</span> <span class="o">...</span> <span class="n">f_d</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="n">e_d</span>
</pre></div>
</div>
<p>where each <code class="docutils literal notranslate"><span class="pre">f_i</span></code> is a monic polynomial and <code class="docutils literal notranslate"><span class="pre">gcd(f_i,</span> <span class="pre">f_j)</span> <span class="pre">==</span> <span class="pre">1</span></code>,
for <code class="docutils literal notranslate"><span class="pre">i</span> <span class="pre">!=</span> <span class="pre">j</span></code>.  The result is given as a tuple consisting of the
leading coefficient of <code class="docutils literal notranslate"><span class="pre">f</span></code> and a list of factors of <code class="docutils literal notranslate"><span class="pre">f</span></code> with
their multiplicities.</p>
<p>The algorithm proceeds by first computing square-free decomposition
of <code class="docutils literal notranslate"><span class="pre">f</span></code> and then iteratively factoring each of square-free factors.</p>
<p>Consider a non square-free polynomial <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">(7*x</span> <span class="pre">+</span> <span class="pre">1)</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">2)**2</span></code> in
<code class="docutils literal notranslate"><span class="pre">GF(11)[x]</span></code>. We obtain its factorization into irreducibles as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_factor</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_factor</span><span class="p">(</span><span class="n">ZZ</span><span class="o">.</span><span class="n">map</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">]),</span> <span class="mi">11</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">(5, [([1, 2], 1), ([1, 8], 2)])</span>
</pre></div>
</div>
<p>We arrived with factorization <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">=</span> <span class="pre">5</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">2)</span> <span class="pre">(x</span> <span class="pre">+</span> <span class="pre">8)**2</span></code>. We didn’t
recover the exact form of the input polynomial because we requested to
get monic factors of <code class="docutils literal notranslate"><span class="pre">f</span></code> and its leading coefficient separately.</p>
<p>Square-free factors of <code class="docutils literal notranslate"><span class="pre">f</span></code> can be factored into irreducibles over
<code class="docutils literal notranslate"><span class="pre">GF(p)</span></code> using three very different methods:</p>
<dl class="simple">
<dt>Berlekamp</dt><dd><p>efficient for very small values of <code class="docutils literal notranslate"><span class="pre">p</span></code> (usually <code class="docutils literal notranslate"><span class="pre">p</span> <span class="pre">&lt;</span> <span class="pre">25</span></code>)</p>
</dd>
<dt>Cantor-Zassenhaus</dt><dd><p>efficient on average input and with “typical” <code class="docutils literal notranslate"><span class="pre">p</span></code></p>
</dd>
<dt>Shoup-Kaltofen-Gathen</dt><dd><p>efficient with very large inputs and modulus</p>
</dd>
</dl>
<p>If you want to use a specific factorization method, instead of the default
one, set <code class="docutils literal notranslate"><span class="pre">GF_FACTOR_METHOD</span></code> with one of <code class="docutils literal notranslate"><span class="pre">berlekamp</span></code>, <code class="docutils literal notranslate"><span class="pre">zassenhaus</span></code> or
<code class="docutils literal notranslate"><span class="pre">shoup</span></code> values.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r652"><span class="brackets"><a class="fn-backref" href="#id16">R652</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id15"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_value">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2194-L2211"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Value of polynomial ‘f’ at ‘a’ in field R.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_value</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gf_value</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="mi">11</span><span class="p">)</span>
<span class="go">2204</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.galoistools.gf_csolve">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.galoistools.</span></span><span class="sig-name descname"><span class="pre">gf_csolve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/galoistools.py#L2323-L2355"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.galoistools.gf_csolve" title="Permalink to this definition">¶</a></dt>
<dd><p>To solve f(x) congruent 0 mod(n).</p>
<p>n is divided into canonical factors and f(x) cong 0 mod(p**e) will be
solved for each factor. Applying the Chinese Remainder Theorem to the
results returns the final answers.</p>
<p class="rubric">Examples</p>
<p>Solve [1, 1, 7] congruent 0 mod(189):</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.galoistools</span> <span class="kn">import</span> <span class="n">gf_csolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gf_csolve</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span> <span class="mi">189</span><span class="p">)</span>
<span class="go">[13, 49, 76, 112, 139, 175]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r653"><span class="brackets"><a class="fn-backref" href="#id17">R653</a></span></dt>
<dd><p>‘An introduction to the Theory of Numbers’ 5th Edition by Ivan Niven,
Zuckerman and Montgomery.</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="manipulation-of-sparse-distributed-polynomials-and-vectors">
<h3>Manipulation of sparse, distributed polynomials and vectors<a class="headerlink" href="#manipulation-of-sparse-distributed-polynomials-and-vectors" title="Permalink to this headline">¶</a></h3>
<p>Dense representations quickly require infeasible amounts of storage and
computation time if the number of variables increases. For this reason,
there is code to manipulate polynomials in a <em>sparse</em> representation. The Ring
object and elements are implemented by the classes <a class="reference internal" href="domainsref.html#sympy.polys.rings.PolyRing" title="sympy.polys.rings.PolyRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">PolyRing</span></code></a> and
<a class="reference internal" href="domainsref.html#sympy.polys.rings.PolyElement" title="sympy.polys.rings.PolyElement"><code class="xref py py-class docutils literal notranslate"><span class="pre">PolyElement</span></code></a>.</p>
<p>In commutative algebra, one often studies not only polynomials, but also
<em>modules</em> over polynomial rings. The polynomial manipulation module provides
rudimentary low-level support for finitely generated free modules. This is
mainly used for Groebner basis computations (see there), so manipulation
functions are only provided to the extend needed. They carry the prefix
<code class="docutils literal notranslate"><span class="pre">sdm_</span></code>. Note that in examples, the generators of the free module are called
<span class="math notranslate nohighlight">\(f_1, f_2, \ldots\)</span>.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_monomial_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_monomial_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">X</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L43-L57"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_monomial_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply tuple <code class="docutils literal notranslate"><span class="pre">X</span></code> representing a monomial of <span class="math notranslate nohighlight">\(K[X]\)</span> into the tuple
<code class="docutils literal notranslate"><span class="pre">M</span></code> representing a monomial of <span class="math notranslate nohighlight">\(F\)</span>.</p>
<p class="rubric">Examples</p>
<p>Multiplying <span class="math notranslate nohighlight">\(xy^3\)</span> into <span class="math notranslate nohighlight">\(x f_1\)</span> yields <span class="math notranslate nohighlight">\(x^2 y^3 f_1\)</span>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_monomial_mul</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_mul</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">(1, 2, 3)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_monomial_deg">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_monomial_deg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L60-L73"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_monomial_deg" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the total degree of <code class="docutils literal notranslate"><span class="pre">M</span></code>.</p>
<p class="rubric">Examples</p>
<p>For example, the total degree of <span class="math notranslate nohighlight">\(x^2 y f_5\)</span> is 3:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_monomial_deg</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_deg</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_monomial_divides">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_monomial_divides</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L96-L145"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_monomial_divides" title="Permalink to this definition">¶</a></dt>
<dd><p>Does there exist a (polynomial) monomial X such that XA = B?</p>
<p class="rubric">Examples</p>
<p>Positive examples:</p>
<p>In the following examples, the monomial is given in terms of x, y and the
generator(s), f_1, f_2 etc. The tuple form of that monomial is used in
the call to sdm_monomial_divides.
Note: the generator appears last in the expression but first in the tuple
and other factors appear in the same order that they appear in the monomial
expression.</p>
<p><span class="math notranslate nohighlight">\(A = f_1\)</span> divides <span class="math notranslate nohighlight">\(B = f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_monomial_divides</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\(A = f_1\)</span> divides <span class="math notranslate nohighlight">\(B = x^2 y f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\(A = xy f_5\)</span> divides <span class="math notranslate nohighlight">\(B = x^2 y f_5\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Negative examples:</p>
<p><span class="math notranslate nohighlight">\(A = f_1\)</span> does not divide <span class="math notranslate nohighlight">\(B = f_2\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\(A = x f_1\)</span> does not divide <span class="math notranslate nohighlight">\(B = f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\(A = xy^2 f_5\)</span> does not divide <span class="math notranslate nohighlight">\(B = y f_5\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_monomial_divides</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_LC">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_LC</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L150-L155"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_LC" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading coeffcient of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_to_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_to_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L158-L160"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_to_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a dictionary from a distributed polynomial.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_from_dict">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_from_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">d</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L163-L178"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_from_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an sdm from a dictionary.</p>
<p>Here <code class="docutils literal notranslate"><span class="pre">O</span></code> is the monomial order to use.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_from_dict</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">lex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dic</span> <span class="o">=</span> <span class="p">{(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_from_dict</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">lex</span><span class="p">)</span>
<span class="go">[((1, 1, 0), 1), ((1, 0, 0), 2)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_add">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L191-L238"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add two module elements <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>Addition is done over the ground field <code class="docutils literal notranslate"><span class="pre">K</span></code>, monomials are ordered
according to <code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p class="rubric">Examples</p>
<p>All examples use lexicographic order.</p>
<p><span class="math notranslate nohighlight">\((xy f_1) + (f_2) = f_2 + xy f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_add</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_add</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">[((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((2, 0, 0), 1), ((1, 1, 1), 1)]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\((xy f_1) + (-xy f_1)\)</span> = 0`</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_add</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">))],</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\((f_1) + (2f_1) = 3f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_add</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">))],</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((1, 0, 0), 3)]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\((yf_1) + (xf_1) = xf_1 + yf_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_add</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((1, 1, 0), 1), ((1, 0, 1), 1)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_LM">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_LM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L241-L256"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_LM" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading monomial of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Only valid if <span class="math notranslate nohighlight">\(f \ne 0\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_LM</span><span class="p">,</span> <span class="n">sdm_from_dict</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">lex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dic</span> <span class="o">=</span> <span class="p">{(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_LM</span><span class="p">(</span><span class="n">sdm_from_dict</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">lex</span><span class="p">))</span>
<span class="go">(4, 0, 1)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_LT">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_LT</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L259-L274"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_LT" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the leading term of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>Only valid if <span class="math notranslate nohighlight">\(f \ne 0\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_LT</span><span class="p">,</span> <span class="n">sdm_from_dict</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">lex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dic</span> <span class="o">=</span> <span class="p">{(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">)}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_LT</span><span class="p">(</span><span class="n">sdm_from_dict</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">lex</span><span class="p">))</span>
<span class="go">((4, 0, 1), 3)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_mul_term">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_mul_term</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">term</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L277-L318"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_mul_term" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiply a distributed module element <code class="docutils literal notranslate"><span class="pre">f</span></code> by a (polynomial) term <code class="docutils literal notranslate"><span class="pre">term</span></code>.</p>
<p>Multiplication of coefficients is done over the ground field <code class="docutils literal notranslate"><span class="pre">K</span></code>, and
monomials are ordered according to <code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p class="rubric">Examples</p>
<p><span class="math notranslate nohighlight">\(0 f_1 = 0\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_mul_term</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_mul_term</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)),</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\(x 0 = 0\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_mul_term</span><span class="p">([],</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\((x) (f_1) = xf_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_mul_term</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))],</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((1, 1, 0), 1)]</span>
</pre></div>
</div>
<p><span class="math notranslate nohighlight">\((2xy) (3x f_1 + 4y f_2) = 8xy^2 f_2 + 6x^2y f_1\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)),</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_mul_term</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((2, 1, 2), 8), ((1, 2, 1), 6)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_zero">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_zero</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L321-L323"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_zero" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the zero module element.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_deg">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_deg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L326-L340"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_deg" title="Permalink to this definition">¶</a></dt>
<dd><p>Degree of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>This is the maximum of the degrees of all its monomials.
Invalid if <code class="docutils literal notranslate"><span class="pre">f</span></code> is zero.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_deg</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_deg</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">),</span> <span class="p">((</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">),</span> <span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="mi">4</span><span class="p">)])</span>
<span class="go">7</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_from_vector">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_from_vector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vec</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">opts</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L345-L367"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_from_vector" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an sdm from an iterable of expressions.</p>
<p>Coefficients are created in the ground field <code class="docutils literal notranslate"><span class="pre">K</span></code>, and terms are ordered
according to monomial order <code class="docutils literal notranslate"><span class="pre">O</span></code>. Named arguments are passed on to the
polys conversion code and can be used to specify for example generators.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_from_vector</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">lex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_from_vector</span><span class="p">([</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">z</span><span class="p">],</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((1, 0, 0, 1), 2), ((0, 2, 0, 0), 1), ((0, 0, 2, 0), 1)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_to_vector">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_to_vector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L370-L399"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_to_vector" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert sdm <code class="docutils literal notranslate"><span class="pre">f</span></code> into a list of polynomial expressions.</p>
<p>The generators for the polynomial ring are specified via <code class="docutils literal notranslate"><span class="pre">gens</span></code>. The rank
of the module is guessed, or passed via <code class="docutils literal notranslate"><span class="pre">n</span></code>. The ground field is assumed
to be <code class="docutils literal notranslate"><span class="pre">K</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_to_vector</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_to_vector</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">],</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[x**2 + y**2, 2*z]</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="polynomial-factorization-algorithms">
<h3>Polynomial factorization algorithms<a class="headerlink" href="#polynomial-factorization-algorithms" title="Permalink to this headline">¶</a></h3>
<p>Many variants of Euclid’s algorithm:</p>
<section id="classical-remainder-sequence">
<h4>Classical remainder sequence<a class="headerlink" href="#classical-remainder-sequence" title="Permalink to this headline">¶</a></h4>
<p>Let <span class="math notranslate nohighlight">\(K\)</span> be a field, and consider the ring <span class="math notranslate nohighlight">\(K[X]\)</span> of polynomials in a single
indeterminate <span class="math notranslate nohighlight">\(X\)</span> with coefficients in <span class="math notranslate nohighlight">\(K\)</span>. Given two elements <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>
of <span class="math notranslate nohighlight">\(K[X]\)</span> with <span class="math notranslate nohighlight">\(g\neq 0\)</span> there are unique polynomials <span class="math notranslate nohighlight">\(q\)</span> and <span class="math notranslate nohighlight">\(r\)</span> such that
<span class="math notranslate nohighlight">\(f = qg + r\)</span> and <span class="math notranslate nohighlight">\(\deg(r) &lt; \deg(g)\)</span> or <span class="math notranslate nohighlight">\(r = 0\)</span>.
They are denoted by <span class="math notranslate nohighlight">\(\mathrm{quo}(f,g)\)</span>
(<em>quotient</em>) and <span class="math notranslate nohighlight">\(\mathrm{rem}(f,g)\)</span> (<em>remainder</em>), so we have
the <em>division identity</em></p>
<div class="math notranslate nohighlight">
\[f = \mathrm{quo}(f,g)g + \mathrm{rem}(f,g).\]</div>
<p>It follows that every ideal <span class="math notranslate nohighlight">\(I\)</span> of <span class="math notranslate nohighlight">\(K[X]\)</span> is a principal ideal, generated by
any element <span class="math notranslate nohighlight">\(\neq 0\)</span> of minimum degree (assuming <span class="math notranslate nohighlight">\(I\)</span> non-zero). In fact,
if <span class="math notranslate nohighlight">\(g\)</span> is such a polynomial and <span class="math notranslate nohighlight">\(f\)</span> is any element of <span class="math notranslate nohighlight">\(I\)</span>,
<span class="math notranslate nohighlight">\(\mathrm{rem}(f,g)\)</span> belongs to <span class="math notranslate nohighlight">\(I\)</span> as a linear combination of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>,
hence must be zero; therefore <span class="math notranslate nohighlight">\(f\)</span> is a multiple of <span class="math notranslate nohighlight">\(g\)</span>.</p>
<p>Using this result it is possible to find a <a class="reference external" href="https://en.wikipedia.org/wiki/Greatest_common_divisor">greatest common
divisor</a>
(gcd) of any polynomials <span class="math notranslate nohighlight">\(f,g,\ldots\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span>.
If <span class="math notranslate nohighlight">\(I\)</span> is the ideal formed by all linear combinations of the given polynomials
with coefficients in <span class="math notranslate nohighlight">\(K[X]\)</span>, and <span class="math notranslate nohighlight">\(d\)</span> is its generator,
then every common divisor of the polynomials also divides <span class="math notranslate nohighlight">\(d\)</span>.
On the other hand, the given polynomials are multiples of the generator <span class="math notranslate nohighlight">\(d\)</span>;
hence <span class="math notranslate nohighlight">\(d\)</span> is a gcd of the polynomials, denoted <span class="math notranslate nohighlight">\(\mathrm{gcd}(f,g,\ldots)\)</span>.</p>
<p>An algorithm for the gcd of two polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span> can
now be obtained as follows.
By the division identity, <span class="math notranslate nohighlight">\(r = \mathrm{rem}(f,g)\)</span> is in the ideal generated
by <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>, as well as <span class="math notranslate nohighlight">\(f\)</span> is in the ideal generated by <span class="math notranslate nohighlight">\(g\)</span> and <span class="math notranslate nohighlight">\(r\)</span>.
Hence the ideals generated by the pairs <span class="math notranslate nohighlight">\((f,g)\)</span> and <span class="math notranslate nohighlight">\((g,r)\)</span> are the same.
Set <span class="math notranslate nohighlight">\(f_0 = f\)</span>, <span class="math notranslate nohighlight">\(f_1 = g\)</span>, and define recursively
<span class="math notranslate nohighlight">\(f_i = \mathrm{rem}(f_{i-2},f_{i-1})\)</span> for <span class="math notranslate nohighlight">\(i\ge 2\)</span>.
The recursion ends after a finite number of steps with <span class="math notranslate nohighlight">\(f_{k+1}=0\)</span>,
since the degrees of the polynomials are strictly decreasing.
By the above remark, all the pairs <span class="math notranslate nohighlight">\((f_{i-1},f_i)\)</span> generate the same ideal.
In particular, the ideal generated by <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> is generated by <span class="math notranslate nohighlight">\(f_k\)</span>
alone as <span class="math notranslate nohighlight">\(f_{k+1} = 0\)</span>. Hence <span class="math notranslate nohighlight">\(d = f_k\)</span> is a gcd of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>.</p>
<p>The sequence of polynomials <span class="math notranslate nohighlight">\(f_0\)</span>, <span class="math notranslate nohighlight">\(f_1,\ldots, f_k\)</span> is called the
<em>Euclidean polynomial remainder sequence</em> determined by <span class="math notranslate nohighlight">\((f,g)\)</span> because
of the analogy with the classical <a class="reference external" href="https://en.wikipedia.org/wiki/Euclidean_algorithm">Euclidean algorithm</a> for the gcd of
natural numbers.</p>
<p>The algorithm may be extended to obtain an expression for <span class="math notranslate nohighlight">\(d\)</span> in terms of
<span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> by using the full division identities
to write recursively each <span class="math notranslate nohighlight">\(f_i\)</span> as a linear combination of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>.
This leads to an equation</p>
<div class="math notranslate nohighlight">
\[d = uf + vg\qquad (u,v \in K[X])\]</div>
<p>analogous to <a class="reference external" href="https://en.wikipedia.org/wiki/Bézout%27s_identity">Bézout’s identity</a>
in the case of integers.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_half_gcdex">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_half_gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L86-L100"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_half_gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Half extended Euclidean algorithm in <span class="math notranslate nohighlight">\(F[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_gcdex">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_gcdex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L130-L144"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_gcdex" title="Permalink to this definition">¶</a></dt>
<dd><p>Extended Euclidean algorithm in <span class="math notranslate nohighlight">\(F[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_invert">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_invert</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L178-L192"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_invert" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute multiplicative inverse of <span class="math notranslate nohighlight">\(f\)</span> modulo <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(F[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_euclidean_prs">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_euclidean_prs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L235-L249"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_euclidean_prs" title="Permalink to this definition">¶</a></dt>
<dd><p>Euclidean polynomial remainder sequence (PRS) in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="simplified-remainder-sequences">
<h4>Simplified remainder sequences<a class="headerlink" href="#simplified-remainder-sequences" title="Permalink to this headline">¶</a></h4>
<p>Assume, as is usual, that the coefficient field <span class="math notranslate nohighlight">\(K\)</span> is
the field of fractions of an integral domain <span class="math notranslate nohighlight">\(A\)</span>.
In this case the coefficients (numerators and denominators)
of the polynomials in the Euclidean remainder sequence
tend to grow very fast.</p>
<p>If <span class="math notranslate nohighlight">\(A\)</span> is a unique factorization domain, the coefficients may be
reduced by cancelling common factors of numerators and denominators.
Further reduction is possible noting that a gcd of polynomials in
<span class="math notranslate nohighlight">\(K[X]\)</span> is not unique:
it may be multiplied by any (non-zero) constant factor.</p>
<p>Any polynomial <span class="math notranslate nohighlight">\(f\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span> can be simplified by extracting
the denominators and common factors of the numerators of its coefficients.
This yields the representation <span class="math notranslate nohighlight">\(f = cF\)</span> where <span class="math notranslate nohighlight">\(c\in K\)</span> is
the <em>content</em> of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(F\)</span> is a <em>primitive</em> polynomial, i.e.,
a polynomial in <span class="math notranslate nohighlight">\(A[X]\)</span> with coprime coefficients.</p>
<p>It is possible to start the algorithm by replacing the given polynomials
<span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> with their primitive parts. This will only modify
<span class="math notranslate nohighlight">\(\mathrm{rem}(f,g)\)</span> by a constant factor.
Replacing it with its primitive part and continuing recursively
we obtain all the primitive parts of the polynomials in
the Euclidean remainder sequence, including the primitive
<span class="math notranslate nohighlight">\(\mathrm{gcd}(f,g)\)</span>.</p>
<p>This sequence is the <em>primitive polynomial remainder sequence</em>.
It is an example of <em>general polynomial remainder sequences</em> where
the computed remainders are modified by constant multipliers (or divisors)
in order to simplify the results.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_primitive_prs">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_primitive_prs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L292-L306"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_primitive_prs" title="Permalink to this definition">¶</a></dt>
<dd><p>Primitive polynomial remainder sequence (PRS) in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="subresultant-sequence">
<h4>Subresultant sequence<a class="headerlink" href="#subresultant-sequence" title="Permalink to this headline">¶</a></h4>
<p>The coefficients of the primitive polynomial sequence do not grow
exceedingly, but the computation of the primitive parts requires
extra processing effort. Besides, the method only works with fraction fields
of unique factorization domains, excluding, for example, the general number
fields.</p>
<p>Collins [Collins67] realized that the so-called <em>subresultant polynomials</em>
of a pair of polynomials also form a generalized remainder sequence.
The coefficients of these polynomials
are expressible as determinants in the coefficients of the given
polynomials. Hence (the logarithm of) their size only grows linearly.
In addition, if the coefficients of the given polynomials
are in the subdomain <span class="math notranslate nohighlight">\(A\)</span>, so are those
of the subresultant polynomials. This means that the subresultant
sequence is comparable to the primitive remainder sequence without
relying on unique factorization in <span class="math notranslate nohighlight">\(A\)</span>.</p>
<p>To see how subresultants are associated with remainder sequences
recall that all polynomials <span class="math notranslate nohighlight">\(h\)</span> in the sequence are linear combinations of
the given polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
<div class="math notranslate nohighlight">
\[h = uf+vg\]</div>
<p>with polynomials <span class="math notranslate nohighlight">\(u\)</span> and <span class="math notranslate nohighlight">\(v\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span>. Moreover, as is seen from the
extended Euclidean algorithm, the degrees of <span class="math notranslate nohighlight">\(u\)</span> and <span class="math notranslate nohighlight">\(v\)</span> are relatively
low, with limited growth from step to step.</p>
<p>Let <span class="math notranslate nohighlight">\(n = \deg(f)\)</span>, and <span class="math notranslate nohighlight">\(m = \deg(g)\)</span>, and assume <span class="math notranslate nohighlight">\(n\ge m\)</span>.
If <span class="math notranslate nohighlight">\(\deg(h) = j &lt; m\)</span>, the coefficients of the powers <span class="math notranslate nohighlight">\(X^k\)</span> (<span class="math notranslate nohighlight">\(k &gt; j\)</span>)
in the products <span class="math notranslate nohighlight">\(uf\)</span> and <span class="math notranslate nohighlight">\(vg\)</span> cancel each other. In particular, the
products must have the same degree, say, <span class="math notranslate nohighlight">\(l\)</span>.
Then <span class="math notranslate nohighlight">\(\deg(u) = l - n\)</span> and <span class="math notranslate nohighlight">\(\deg(v) = l - m\)</span> with a total of <span class="math notranslate nohighlight">\(2l -n - m + 2\)</span>
coefficients to be determined.</p>
<p>On the other hand, the equality <span class="math notranslate nohighlight">\(h = uf + vg\)</span> implies that <span class="math notranslate nohighlight">\(l - j\)</span>
linear combinations of the coefficients are zero, those associated with
the powers <span class="math notranslate nohighlight">\(X^i\)</span> (<span class="math notranslate nohighlight">\(j &lt; i \leq l\)</span>), and one has a given non-zero value,
namely the leading coefficient of <span class="math notranslate nohighlight">\(h\)</span>.</p>
<p>To satisfy these <span class="math notranslate nohighlight">\(l - j + 1\)</span> linear equations the total number of
coefficients to be determined cannot be lower than <span class="math notranslate nohighlight">\(l - j + 1\)</span>, in general.
This leads to the inequality <span class="math notranslate nohighlight">\(l \ge n + m - j - 1\)</span>.
Taking <span class="math notranslate nohighlight">\(l = n + m - j - 1\)</span>, we obtain <span class="math notranslate nohighlight">\(\deg(u) = m - j - 1\)</span> and
<span class="math notranslate nohighlight">\(\deg(v) = n - j - 1\)</span>.</p>
<p>In the case <span class="math notranslate nohighlight">\(j = 0\)</span> the matrix of the resulting system of linear equations
is the <a class="reference external" href="https://en.wikipedia.org/wiki/Sylvester_matrix">Sylvester matrix</a>
<span class="math notranslate nohighlight">\(S(f,g)\)</span> associated to <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>,
an <span class="math notranslate nohighlight">\((n+m)\times (n+m)\)</span> matrix with coefficients of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> as entries.
Its determinant is the <a class="reference external" href="https://en.wikipedia.org/wiki/Resultant">resultant</a>
<span class="math notranslate nohighlight">\(\mathrm{res}(f,g)\)</span> of the pair <span class="math notranslate nohighlight">\((f,g)\)</span>.
It is non-zero if and only if <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> are relatively prime.</p>
<p>For any <span class="math notranslate nohighlight">\(j\)</span> in the interval from <span class="math notranslate nohighlight">\(0\)</span> to <span class="math notranslate nohighlight">\(m\)</span> the matrix of the linear system is
an <span class="math notranslate nohighlight">\((n+m-2j)\times (n+m-2j)\)</span> submatrix of the Sylvester matrix.
Its determinant <span class="math notranslate nohighlight">\(s_j(f,g)\)</span>
is called the <span class="math notranslate nohighlight">\(j\)</span> th <em>scalar subresultant</em> of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span>.</p>
<p>If <span class="math notranslate nohighlight">\(s_j(f,g)\)</span> is not zero, the associated equation <span class="math notranslate nohighlight">\(h = uf + vg\)</span> has
a unique solution where <span class="math notranslate nohighlight">\(\deg(h) = j\)</span> and the leading coefficient
of <span class="math notranslate nohighlight">\(h\)</span> has any given value; the one with leading coefficient
<span class="math notranslate nohighlight">\(s_j(f,g)\)</span> is the <span class="math notranslate nohighlight">\(j\)</span> th <em>subresultant polynomial</em> or, briefly,
<em>subresultant</em> of the pair <span class="math notranslate nohighlight">\((f,g)\)</span>, and denoted <span class="math notranslate nohighlight">\(S_j(f,g)\)</span>.
This choice guarantees that the remainining coefficients
are also certain subdeterminants of the Sylvester matrix.
In particular, if <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> are in <span class="math notranslate nohighlight">\(A[X]\)</span>, so is <span class="math notranslate nohighlight">\(S_j(f,g)\)</span> as well.
This construction of subresultants applies to any <span class="math notranslate nohighlight">\(j\)</span> between
<span class="math notranslate nohighlight">\(0\)</span> and <span class="math notranslate nohighlight">\(m\)</span> regardless of the value of <span class="math notranslate nohighlight">\(s_j(f,g)\)</span>; if it is zero, then
<span class="math notranslate nohighlight">\(\deg(S_j(f,g)) &lt; j\)</span>.</p>
<p>The properties of subresultants are as follows. Let <span class="math notranslate nohighlight">\(n_0 = \deg(f)\)</span>,
<span class="math notranslate nohighlight">\(n_1 = \deg(g)\)</span>, <span class="math notranslate nohighlight">\(n_2, \ldots, n_k\)</span> be the decreasing sequence of
degrees of polynomials in a remainder sequence.
Let <span class="math notranslate nohighlight">\(0 \le j \le n_1\)</span>; then</p>
<ul class="simple">
<li><p><span class="math notranslate nohighlight">\(s_j(f,g)\ne 0\)</span> if and only if <span class="math notranslate nohighlight">\(j = n_i\)</span> for some <span class="math notranslate nohighlight">\(i\)</span>.</p></li>
<li><p><span class="math notranslate nohighlight">\(S_j(f,g)\ne 0\)</span> if and only if <span class="math notranslate nohighlight">\(j = n_i\)</span> or <span class="math notranslate nohighlight">\(j = n_i - 1\)</span> for some <span class="math notranslate nohighlight">\(i\)</span>.</p></li>
</ul>
<p>Normally, <span class="math notranslate nohighlight">\(n_{i-1} - n_i = 1\)</span> for <span class="math notranslate nohighlight">\(1 &lt; i \le k\)</span>. If <span class="math notranslate nohighlight">\(n_{i-1} - n_i &gt; 1\)</span>
for some <span class="math notranslate nohighlight">\(i\)</span> (the <em>abnormal</em> case), then <span class="math notranslate nohighlight">\(S_{n_{i-1}-1}(f,g)\)</span> and
<span class="math notranslate nohighlight">\(S_{n_i}(f,g)\)</span> are constant multiples of each other.
Hence either one could be included in the polynomial remainder sequence.
The former is given by smaller determinants,
so it is expected to have smaller coefficients.</p>
<p>Collins defined the <em>subresultant remainder sequence</em> by setting</p>
<div class="math notranslate nohighlight">
\[f_i = S_{n_{i-1}-1}(f,g) \qquad (2\le i \le k).\]</div>
<p>In the normal case, these are the same as the <span class="math notranslate nohighlight">\(S_{n_i}(f,g)\)</span>. He also
derived expressions for the constants <span class="math notranslate nohighlight">\(\gamma_i\)</span> in the remainder
formulas</p>
<div class="math notranslate nohighlight">
\[\gamma_i f_i = \mathrm{rem}(f_{i-2},f_{i-1})\]</div>
<p>in terms of the leading coefficients of <span class="math notranslate nohighlight">\(f_1,\ldots,f_{i-1}\)</span>, working
in the field <span class="math notranslate nohighlight">\(K\)</span>.</p>
<p>Brown and Traub [BrownTraub71] later developed a recursive procedure
for computing the coefficients <span class="math notranslate nohighlight">\(\gamma_i\)</span>. Their algorithm deals with elements
of the domain <span class="math notranslate nohighlight">\(A\)</span> exclusively (assuming <span class="math notranslate nohighlight">\(f,g\in A[X]\)</span>). However, in the
abnormal case there was a problem, a division in <span class="math notranslate nohighlight">\(A\)</span>
which could only be conjectured to be exact.</p>
<p>This was subsequently justified by Brown [Brown78] who showed that
the result of the division is, in fact, a scalar subresultant.
More specifically, the constant appearing in the computation of <span class="math notranslate nohighlight">\(f_i\)</span> is
<span class="math notranslate nohighlight">\(s_{n_{i-2}}(f,g)\)</span> (Theorem 3).
The implication of this discovery is that the scalar subresultants
are computed as by-products of the algorithm, all but <span class="math notranslate nohighlight">\(s_{n_k}(f,g)\)</span>
which is not needed after finding <span class="math notranslate nohighlight">\(f_{k+1} = 0\)</span>.
Completing the last step we obtain all non-zero scalar subresultants,
including the last one which is the resultant if this does not vanish.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_inner_subresultants">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_inner_subresultants</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L450-L527"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_inner_subresultants" title="Permalink to this definition">¶</a></dt>
<dd><p>Subresultant PRS algorithm in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">9</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">27</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="mi">12</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">7</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">6</span> <span class="o">-</span> <span class="mi">54</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">729</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">216</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">16</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">prs</span> <span class="o">=</span> <span class="p">[</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sres</span> <span class="o">=</span> <span class="p">[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">12</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">54</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">729</span><span class="p">,</span> <span class="o">-</span><span class="mi">216</span><span class="p">,</span> <span class="mi">16</span><span class="p">]]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_inner_subresultants</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span> <span class="o">==</span> <span class="p">(</span><span class="n">prs</span><span class="p">,</span> <span class="n">sres</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_subresultants">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_subresultants</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L530-L550"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_subresultants" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes subresultant PRS of two polynomials in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">9</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">27</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="mi">12</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">7</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">6</span> <span class="o">-</span> <span class="mi">54</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">729</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">216</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">16</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_subresultants</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span> <span class="o">==</span> <span class="p">[</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">]</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_prs_resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_prs_resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L553-L590"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_prs_resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Resultant algorithm in <span class="math notranslate nohighlight">\(K[X]\)</span> using subresultant PRS.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">9</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">27</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="mi">12</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">7</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">6</span> <span class="o">-</span> <span class="mi">54</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">4</span> <span class="o">+</span> <span class="mi">8</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">729</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">216</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">16</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">,</span> <span class="n">prs</span> <span class="o">=</span> <span class="n">R</span><span class="o">.</span><span class="n">dmp_prs_resultant</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">res</span> <span class="o">==</span> <span class="n">b</span>             <span class="c1"># resultant has n-1 variables</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span> <span class="o">==</span> <span class="n">b</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prs</span> <span class="o">==</span> <span class="p">[</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">]</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_zz_modular_resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_modular_resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L593-L663"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_zz_modular_resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute resultant of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> modulo a prime <span class="math notranslate nohighlight">\(p\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_zz_modular_resultant</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">-2*y**2 + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_zz_collins_resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_collins_resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L671-L727"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_zz_collins_resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Collins’s modular resultant algorithm in <span class="math notranslate nohighlight">\(Z[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_zz_collins_resultant</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">-2*y**2 - 5*y + 1</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_qq_collins_resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_qq_collins_resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L730-L766"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_qq_collins_resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Collins’s modular resultant algorithm in <span class="math notranslate nohighlight">\(Q[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">3</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_qq_collins_resultant</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">-2*y**2 - 7/3*y + 5/6</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_resultant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_resultant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">includePRS</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L769-L799"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_resultant" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes resultant of two polynomials in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">9</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_resultant</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">-3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_discriminant">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_discriminant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L829-L857"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_discriminant" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes discriminant of a polynomial in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">,</span><span class="n">t</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y,z,t&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_discriminant</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">z</span> <span class="o">+</span> <span class="n">t</span><span class="p">)</span>
<span class="go">-4*y*t + z**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_rr_prs_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_rr_prs_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1036-L1079"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_rr_prs_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial GCD using subresultants over a ring.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>, <code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code>,
and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_rr_prs_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">(x + y, x + y, x)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_ff_prs_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_ff_prs_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1082-L1123"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_ff_prs_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial GCD using subresultants over a field.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>, <code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code>,
and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_ff_prs_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">(x + y, 1/2*x + 1/2*y, x)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_zz_heu_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_heu_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1267-L1371"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_zz_heu_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Heuristic polynomial GCD in <span class="math notranslate nohighlight">\(Z[X]\)</span>.</p>
<p>Given univariate polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(Z[X]\)</span>, returns
their GCD and cofactors, i.e. polynomials <code class="docutils literal notranslate"><span class="pre">h</span></code>, <code class="docutils literal notranslate"><span class="pre">cff</span></code> and <code class="docutils literal notranslate"><span class="pre">cfg</span></code>
such that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">h</span> <span class="o">=</span> <span class="n">gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">),</span> <span class="n">cff</span> <span class="o">=</span> <span class="n">quo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span> <span class="ow">and</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">quo</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
</pre></div>
</div>
<p>The algorithm is purely heuristic which means it may fail to compute
the GCD. This will be signaled by raising an exception. In this case
you will need to switch to another GCD method.</p>
<p>The algorithm computes the polynomial GCD by evaluating polynomials
f and g at certain points and computing (fast) integer GCD of those
evaluations. The polynomial GCD is recovered from the integer image
by interpolation. The evaluation process reduces f and g variable by
variable into a large integer.  The final step is to verify if the
interpolated polynomial is the correct GCD. This gives cofactors of
the input polynomials as a side effect.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_zz_heu_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">(x + y, x + y, x)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r654"><span class="brackets"><a class="fn-backref" href="#id19">R654</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#liao95" id="id18"><span>[Liao95]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_qq_heu_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_qq_heu_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1423-L1469"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_qq_heu_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Heuristic polynomial GCD in <span class="math notranslate nohighlight">\(Q[X]\)</span>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>,
<code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code>, and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_qq_heu_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">(x + 2*y, 1/4*x + 1/2*y, 1/2*x)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_inner_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_inner_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1559-L1587"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_inner_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial GCD and cofactors of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p>Returns <code class="docutils literal notranslate"><span class="pre">(h,</span> <span class="pre">cff,</span> <span class="pre">cfg)</span></code> such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">gcd(f,</span> <span class="pre">g)</span></code>,
<code class="docutils literal notranslate"><span class="pre">cff</span> <span class="pre">=</span> <span class="pre">quo(f,</span> <span class="pre">h)</span></code>, and <code class="docutils literal notranslate"><span class="pre">cfg</span> <span class="pre">=</span> <span class="pre">quo(g,</span> <span class="pre">h)</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_inner_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">(x + y, x + y, x)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_gcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_gcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1607-L1624"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_gcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial GCD of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_gcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">x + y</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_lcm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_lcm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1746-L1769"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_lcm" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes polynomial LCM of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_lcm</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="go">x**3 + 2*x**2*y + x*y**2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_content">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_content</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1772-L1800"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_content" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns GCD of multivariate coefficients.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_content</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">2*y + 6</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_primitive">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_primitive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1803-L1822"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_primitive" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns multivariate content and a primitive polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_primitive</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">12</span><span class="p">)</span>
<span class="go">(2*y + 6, x + 2)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.euclidtools.dmp_cancel">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.euclidtools.</span></span><span class="sig-name descname"><span class="pre">dmp_cancel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">include</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/euclidtools.py#L1842-L1892"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.euclidtools.dmp_cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel common factors in a rational function <span class="math notranslate nohighlight">\(f/g\)</span>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_cancel</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">(2*x + 2, x - 1)</span>
</pre></div>
</div>
</dd></dl>

<p>Polynomial factorization in characteristic zero:</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_trial_division">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_trial_division</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factors</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L102-L122"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_trial_division" title="Permalink to this definition">¶</a></dt>
<dd><p>Determine multiplicities of factors for a multivariate polynomial
using trial division.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_mignotte_bound">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_mignotte_bound</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L185-L191"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_mignotte_bound" title="Permalink to this definition">¶</a></dt>
<dd><p>Mignotte bound for multivariate polynomials in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_hensel_step">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_hensel_step</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">m</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">h</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">t</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L194-L248"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_hensel_step" title="Permalink to this definition">¶</a></dt>
<dd><p>One step in Hensel lifting in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
<p>Given positive integer <span class="math notranslate nohighlight">\(m\)</span> and <span class="math notranslate nohighlight">\(Z[x]\)</span> polynomials <span class="math notranslate nohighlight">\(f\)</span>, <span class="math notranslate nohighlight">\(g\)</span>, <span class="math notranslate nohighlight">\(h\)</span>, <span class="math notranslate nohighlight">\(s\)</span>
and <span class="math notranslate nohighlight">\(t\)</span> such that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">g</span><span class="o">*</span><span class="n">h</span> <span class="p">(</span><span class="n">mod</span> <span class="n">m</span><span class="p">)</span>
<span class="n">s</span><span class="o">*</span><span class="n">g</span> <span class="o">+</span> <span class="n">t</span><span class="o">*</span><span class="n">h</span> <span class="o">=</span> <span class="mi">1</span> <span class="p">(</span><span class="n">mod</span> <span class="n">m</span><span class="p">)</span>

<span class="n">lc</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">a</span> <span class="n">zero</span> <span class="n">divisor</span> <span class="p">(</span><span class="n">mod</span> <span class="n">m</span><span class="p">)</span>
<span class="n">lc</span><span class="p">(</span><span class="n">h</span><span class="p">)</span> <span class="o">=</span> <span class="mi">1</span>

<span class="n">deg</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="o">=</span> <span class="n">deg</span><span class="p">(</span><span class="n">g</span><span class="p">)</span> <span class="o">+</span> <span class="n">deg</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
<span class="n">deg</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">deg</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
<span class="n">deg</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">deg</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<p>returns polynomials <span class="math notranslate nohighlight">\(G\)</span>, <span class="math notranslate nohighlight">\(H\)</span>, <span class="math notranslate nohighlight">\(S\)</span> and <span class="math notranslate nohighlight">\(T\)</span>, such that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">G</span><span class="o">*</span><span class="n">H</span> <span class="p">(</span><span class="n">mod</span> <span class="n">m</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="n">S</span><span class="o">*</span><span class="n">G</span> <span class="o">+</span> <span class="n">T</span><span class="o">*</span><span class="n">H</span> <span class="o">=</span> <span class="mi">1</span> <span class="p">(</span><span class="n">mod</span> <span class="n">m</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r655"><span class="brackets"><a class="fn-backref" href="#id21">R655</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id20"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_hensel_lift">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_hensel_lift</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L251-L306"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_hensel_lift" title="Permalink to this definition">¶</a></dt>
<dd><p>Multifactor Hensel lifting in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
<p>Given a prime <span class="math notranslate nohighlight">\(p\)</span>, polynomial <span class="math notranslate nohighlight">\(f\)</span> over <span class="math notranslate nohighlight">\(Z[x]\)</span> such that <span class="math notranslate nohighlight">\(lc(f)\)</span>
is a unit modulo <span class="math notranslate nohighlight">\(p\)</span>, monic pair-wise coprime polynomials <span class="math notranslate nohighlight">\(f_i\)</span>
over <span class="math notranslate nohighlight">\(Z[x]\)</span> satisfying:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">lc</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="n">f_1</span> <span class="o">...</span> <span class="n">f_r</span> <span class="p">(</span><span class="n">mod</span> <span class="n">p</span><span class="p">)</span>
</pre></div>
</div>
<p>and a positive integer <span class="math notranslate nohighlight">\(l\)</span>, returns a list of monic polynomials
<span class="math notranslate nohighlight">\(F_1\)</span>, <span class="math notranslate nohighlight">\(F_2\)</span>, …, <span class="math notranslate nohighlight">\(F_r\)</span> satisfying:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">lc</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="n">F_1</span> <span class="o">...</span> <span class="n">F_r</span> <span class="p">(</span><span class="n">mod</span> <span class="n">p</span><span class="o">**</span><span class="n">l</span><span class="p">)</span>

<span class="n">F_i</span> <span class="o">=</span> <span class="n">f_i</span> <span class="p">(</span><span class="n">mod</span> <span class="n">p</span><span class="p">),</span> <span class="n">i</span> <span class="o">=</span> <span class="mf">1.</span><span class="o">.</span><span class="n">r</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r656"><span class="brackets"><a class="fn-backref" href="#id23">R656</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id22"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_zassenhaus">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_zassenhaus</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L315-L415"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_zassenhaus" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor primitive square-free polynomials in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_irreducible_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_irreducible_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L418-L430"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_irreducible_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Test irreducibility using Eisenstein’s criterion.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_cyclotomic_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_cyclotomic_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">irreducible</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L433-L506"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_cyclotomic_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently test if <code class="docutils literal notranslate"><span class="pre">f</span></code> is a cyclotomic polynomial.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">16</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">14</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">8</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_cyclotomic_p</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">16</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">14</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">10</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">8</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">6</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_cyclotomic_p</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_cyclotomic_poly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_cyclotomic_poly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L509-L517"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_cyclotomic_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently generate n-th cyclotomic polynomial.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_cyclotomic_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_cyclotomic_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L534-L575"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_cyclotomic_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Efficiently factor polynomials <span class="math notranslate nohighlight">\(x**n - 1\)</span> and <span class="math notranslate nohighlight">\(x**n + 1\)</span> in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
<p>Given a univariate polynomial <span class="math notranslate nohighlight">\(f\)</span> in <span class="math notranslate nohighlight">\(Z[x]\)</span> returns a list of factors
of <span class="math notranslate nohighlight">\(f\)</span>, provided that <span class="math notranslate nohighlight">\(f\)</span> is in the form <span class="math notranslate nohighlight">\(x**n - 1\)</span> or <span class="math notranslate nohighlight">\(x**n + 1\)</span> for
<span class="math notranslate nohighlight">\(n &gt;= 1\)</span>. Otherwise returns None.</p>
<p>Factorization is performed using cyclotomic decomposition of <span class="math notranslate nohighlight">\(f\)</span>,
which makes this method much faster that any other direct factorization
approach (e.g. Zassenhaus’s).</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r657"><span class="brackets"><a class="fn-backref" href="#id25">R657</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#weisstein09" id="id24"><span>[Weisstein09]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_factor_sqf">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_factor_sqf</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L578-L604"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_factor_sqf" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor square-free (non-primitive) polynomials in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_zz_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_zz_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L607-L679"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_zz_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor (non square-free) polynomials in <span class="math notranslate nohighlight">\(Z[x]\)</span>.</p>
<p>Given a univariate polynomial <span class="math notranslate nohighlight">\(f\)</span> in <span class="math notranslate nohighlight">\(Z[x]\)</span> computes its complete
factorization <span class="math notranslate nohighlight">\(f_1, ..., f_n\)</span> into irreducibles over integers:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="n">f_1</span><span class="o">**</span><span class="n">k_1</span> <span class="o">...</span> <span class="n">f_n</span><span class="o">**</span><span class="n">k_n</span>
</pre></div>
</div>
<p>The factorization is computed by reducing the input polynomial
into a primitive square-free polynomial and factoring it using
Zassenhaus algorithm. Trial division is used to recover the
multiplicities of factors.</p>
<p>The result is returned as a tuple consisting of:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">content</span><span class="p">(</span><span class="n">f</span><span class="p">),</span> <span class="p">[(</span><span class="n">f_1</span><span class="p">,</span> <span class="n">k_1</span><span class="p">),</span> <span class="o">...</span><span class="p">,</span> <span class="p">(</span><span class="n">f_n</span><span class="p">,</span> <span class="n">k_n</span><span class="p">))</span>
</pre></div>
</div>
<p class="rubric">Examples</p>
<p>Consider the polynomial <span class="math notranslate nohighlight">\(f = 2*x**4 - 2\)</span>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dup_zz_factor</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">4</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">(2, [(x - 1, 1), (x + 1, 1), (x**2 + 1, 1)])</span>
</pre></div>
</div>
<p>In result we got the following factorization:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Note that this is a complete factorization over integers,
however over Gaussian integers we can factor the last term.</p>
<p>By default, polynomials <span class="math notranslate nohighlight">\(x**n - 1\)</span> and <span class="math notranslate nohighlight">\(x**n + 1\)</span> are factored
using cyclotomic decomposition to speedup computations. To
disable this behaviour set cyclotomic=False.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r658"><span class="brackets"><a class="fn-backref" href="#id27">R658</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id26"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_wang_non_divisors">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_wang_non_divisors</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">E</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ct</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L682-L699"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_wang_non_divisors" title="Permalink to this definition">¶</a></dt>
<dd><p>Wang/EEZ: Compute a set of valid divisors.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_wang_test_points">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_wang_test_points</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ct</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L702-L725"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_wang_test_points" title="Permalink to this definition">¶</a></dt>
<dd><p>Wang/EEZ: Test evaluation points for suitability.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_wang_lead_coeffs">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_wang_lead_coeffs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">E</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">H</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L728-L779"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_wang_lead_coeffs" title="Permalink to this definition">¶</a></dt>
<dd><p>Wang/EEZ: Compute correct leading coefficients.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_diophantine">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_diophantine</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">d</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L830-L895"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_diophantine" title="Permalink to this definition">¶</a></dt>
<dd><p>Wang/EEZ: Solve multivariate Diophantine equations.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_wang_hensel_lifting">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_wang_hensel_lifting</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">H</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">LC</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">A</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L898-L947"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_wang_hensel_lifting" title="Permalink to this definition">¶</a></dt>
<dd><p>Wang/EEZ: Parallel Hensel lifting algorithm.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_wang">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_wang</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L950-L1089"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_wang" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor primitive square-free polynomials in <span class="math notranslate nohighlight">\(Z[X]\)</span>.</p>
<p>Given a multivariate polynomial <span class="math notranslate nohighlight">\(f\)</span> in <span class="math notranslate nohighlight">\(Z[x_1,...,x_n]\)</span>, which is
primitive and square-free in <span class="math notranslate nohighlight">\(x_1\)</span>, computes factorization of <span class="math notranslate nohighlight">\(f\)</span> into
irreducibles over integers.</p>
<p>The procedure is based on Wang’s Enhanced Extended Zassenhaus
algorithm. The algorithm works by viewing <span class="math notranslate nohighlight">\(f\)</span> as a univariate polynomial
in <span class="math notranslate nohighlight">\(Z[x_2,...,x_n][x_1]\)</span>, for which an evaluation mapping is computed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">x_2</span> <span class="o">-&gt;</span> <span class="n">a_2</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="n">x_n</span> <span class="o">-&gt;</span> <span class="n">a_n</span>
</pre></div>
</div>
<p>where <span class="math notranslate nohighlight">\(a_i\)</span>, for <span class="math notranslate nohighlight">\(i = 2, ..., n\)</span>, are carefully chosen integers.  The
mapping is used to transform <span class="math notranslate nohighlight">\(f\)</span> into a univariate polynomial in <span class="math notranslate nohighlight">\(Z[x_1]\)</span>,
which can be factored efficiently using Zassenhaus algorithm. The last
step is to lift univariate factors to obtain true multivariate
factors. For this purpose a parallel Hensel lifting procedure is used.</p>
<p>The parameter <code class="docutils literal notranslate"><span class="pre">seed</span></code> is passed to _randint and can be used to seed randint
(when an integer) or (for testing purposes) can be a sequence of numbers.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r659"><span class="brackets"><a class="fn-backref" href="#id30">R659</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#wang78" id="id28"><span>[Wang78]</span></a></p>
</dd>
<dt class="label" id="r660"><span class="brackets"><a class="fn-backref" href="#id31">R660</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#geddes92" id="id29"><span>[Geddes92]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_zz_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_zz_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1092-L1154"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_zz_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor (non square-free) polynomials in <span class="math notranslate nohighlight">\(Z[X]\)</span>.</p>
<p>Given a multivariate polynomial <span class="math notranslate nohighlight">\(f\)</span> in <span class="math notranslate nohighlight">\(Z[x]\)</span> computes its complete
factorization <span class="math notranslate nohighlight">\(f_1, ..., f_n\)</span> into irreducibles over integers:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="n">content</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="n">f_1</span><span class="o">**</span><span class="n">k_1</span> <span class="o">...</span> <span class="n">f_n</span><span class="o">**</span><span class="n">k_n</span>
</pre></div>
</div>
<p>The factorization is computed by reducing the input polynomial
into a primitive square-free polynomial and factoring it using
Enhanced Extended Zassenhaus (EEZ) algorithm. Trial division
is used to recover the multiplicities of factors.</p>
<p>The result is returned as a tuple consisting of:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">content</span><span class="p">(</span><span class="n">f</span><span class="p">),</span> <span class="p">[(</span><span class="n">f_1</span><span class="p">,</span> <span class="n">k_1</span><span class="p">),</span> <span class="o">...</span><span class="p">,</span> <span class="p">(</span><span class="n">f_n</span><span class="p">,</span> <span class="n">k_n</span><span class="p">))</span>
</pre></div>
</div>
<p>Consider polynomial <span class="math notranslate nohighlight">\(f = 2*(x**2 - y**2)\)</span>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x,y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">dmp_zz_factor</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="go">(2, [(x - y, 1), (x + y, 1)])</span>
</pre></div>
</div>
<p>In result we got the following factorization:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="mi">2</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">y</span><span class="p">)</span> <span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r661"><span class="brackets"><a class="fn-backref" href="#id33">R661</a></span></dt>
<dd><p><a class="reference internal" href="literature.html#gathen99" id="id32"><span>[Gathen99]</span></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_ext_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_ext_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1254-L1281"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_ext_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor multivariate polynomials over algebraic number fields.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dup_gf_factor">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dup_gf_factor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1284-L1293"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dup_gf_factor" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor univariate polynomials over finite fields.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_factor_list">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_factor_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1378-L1452"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_factor_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor multivariate polynomials into irreducibles in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_factor_list_include">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_factor_list_include</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1455-L1466"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_factor_list_include" title="Permalink to this definition">¶</a></dt>
<dd><p>Factor multivariate polynomials into irreducibles in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.factortools.dmp_irreducible_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.factortools.</span></span><span class="sig-name descname"><span class="pre">dmp_irreducible_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/factortools.py#L1477-L1490"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.factortools.dmp_irreducible_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if a multivariate polynomial <code class="docutils literal notranslate"><span class="pre">f</span></code> has no factors
over its domain.</p>
</dd></dl>

</section>
</section>
<section id="groebner-basis-algorithms">
<h3>Groebner basis algorithms<a class="headerlink" href="#groebner-basis-algorithms" title="Permalink to this headline">¶</a></h3>
<p>Groebner bases can be used to answer many problems in computational
commutative algebra. Their computation in rather complicated, and very
performance-sensitive. We present here various low-level implementations of
Groebner basis computation algorithms; please see the previous section of the
manual for usage.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.groebner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">groebner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L10-L48"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.groebner" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes Groebner basis for a set of polynomials in <span class="math notranslate nohighlight">\(K[X]\)</span>.</p>
<p>Wrapper around the (default) improved Buchberger and the other algorithms
for computing Groebner bases. The choice of algorithm can be changed via
<code class="docutils literal notranslate"><span class="pre">method</span></code> argument or <a class="reference internal" href="#sympy.polys.polyconfig.setup" title="sympy.polys.polyconfig.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">sympy.polys.polyconfig.setup()</span></code></a>, where
<code class="docutils literal notranslate"><span class="pre">method</span></code> can be either <code class="docutils literal notranslate"><span class="pre">buchberger</span></code> or <code class="docutils literal notranslate"><span class="pre">f5b</span></code>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.spoly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">spoly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L262-L275"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.spoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute LCM(LM(p1), LM(p2))/LM(p1)*p1 - LCM(LM(p1), LM(p2))/LM(p2)*p2
This is the S-poly provided p1 and p2 are monic</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.red_groebner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">red_groebner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L699-L728"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.red_groebner" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute reduced Groebner basis, from BeckerWeispfenning93, p. 216</p>
<p>Selects a subset of generators, that already generate the ideal
and computes a reduced Groebner basis for them.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.is_groebner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">is_groebner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L731-L742"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.is_groebner" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if G is a Groebner basis.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.is_minimal">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">is_minimal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L745-L762"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.is_minimal" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if G is a minimal Groebner basis.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.groebnertools.is_reduced">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.groebnertools.</span></span><span class="sig-name descname"><span class="pre">is_reduced</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/groebnertools.py#L765-L783"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.groebnertools.is_reduced" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if G is a reduced Groebner basis.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.fglmtools.matrix_fglm">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.fglmtools.</span></span><span class="sig-name descname"><span class="pre">matrix_fglm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">F</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ring</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O_to</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/fglmtools.py#L6-L67"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.fglmtools.matrix_fglm" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the reduced Groebner basis <code class="docutils literal notranslate"><span class="pre">F</span></code> of a zero-dimensional
ideal w.r.t. <code class="docutils literal notranslate"><span class="pre">O_from</span></code> to a reduced Groebner basis
w.r.t. <code class="docutils literal notranslate"><span class="pre">O_to</span></code>.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r662"><span class="brackets"><a class="fn-backref" href="#id34">R662</a></span></dt>
<dd><p>J.C. Faugere, P. Gianni, D. Lazard, T. Mora (1994). Efficient
Computation of Zero-dimensional Groebner Bases by Change of
Ordering</p>
</dd>
</dl>
</dd></dl>

<p>Groebner basis algorithms for modules are also provided:</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_spoly">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_spoly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">phantom</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L404-L453"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_spoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the generalized s-polynomial of <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>.</p>
<p>The ground field is assumed to be <code class="docutils literal notranslate"><span class="pre">K</span></code>, and monomials ordered according to
<code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p>This is invalid if either of <code class="docutils literal notranslate"><span class="pre">f</span></code> or <code class="docutils literal notranslate"><span class="pre">g</span></code> is zero.</p>
<p>If the leading terms of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> involve different basis elements of
<span class="math notranslate nohighlight">\(F\)</span>, their s-poly is defined to be zero. Otherwise it is a certain linear
combination of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in which the leading terms cancel.
See [SCA, defn 2.3.6] for details.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">phantom</span></code> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, it should be a pair of module elements on
which to perform the same operation(s) as on <code class="docutils literal notranslate"><span class="pre">f</span></code> and <code class="docutils literal notranslate"><span class="pre">g</span></code>. The in this
case both results are returned.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_spoly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">lex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_spoly</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_spoly</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">lex</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">[((1, 2, 1), 1)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_ecart">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_ecart</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L456-L474"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_ecart" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the ecart of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
<p>This is defined to be the difference of the total degree of <span class="math notranslate nohighlight">\(f\)</span> and the
total degree of the leading monomial of <span class="math notranslate nohighlight">\(f\)</span> [SCA, defn 2.3.7].</p>
<p>Invalid if f is zero.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.distributedmodules</span> <span class="kn">import</span> <span class="n">sdm_ecart</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_ecart</span><span class="p">([((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">),</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">)])</span>
<span class="go">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sdm_ecart</span><span class="p">([((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">),</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">)])</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_nf_mora">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_nf_mora</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">phantom</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L477-L530"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_nf_mora" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a weak normal form of <code class="docutils literal notranslate"><span class="pre">f</span></code> with respect to <code class="docutils literal notranslate"><span class="pre">G</span></code> and order <code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p>The ground field is assumed to be <code class="docutils literal notranslate"><span class="pre">K</span></code>, and monomials ordered according to
<code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p>Weak normal forms are defined in [SCA, defn 2.3.3]. They are not unique.
This function deterministically computes a weak normal form, depending on
the order of <span class="math notranslate nohighlight">\(G\)</span>.</p>
<p>The most important property of a weak normal form is the following: if
<span class="math notranslate nohighlight">\(R\)</span> is the ring associated with the monomial ordering (if the ordering is
global, we just have <span class="math notranslate nohighlight">\(R = K[x_1, \ldots, x_n]\)</span>, otherwise it is a certain
localization thereof), <span class="math notranslate nohighlight">\(I\)</span> any ideal of <span class="math notranslate nohighlight">\(R\)</span> and <span class="math notranslate nohighlight">\(G\)</span> a standard basis for
<span class="math notranslate nohighlight">\(I\)</span>, then for any <span class="math notranslate nohighlight">\(f \in R\)</span>, we have <span class="math notranslate nohighlight">\(f \in I\)</span> if and only if
<span class="math notranslate nohighlight">\(NF(f | G) = 0\)</span>.</p>
<p>This is the generalized Mora algorithm for computing weak normal forms with
respect to arbitrary monomial orders [SCA, algorithm 2.3.9].</p>
<p>If <code class="docutils literal notranslate"><span class="pre">phantom</span></code> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, it should be a pair of “phantom” arguments
on which to perform the same computations as on <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">G</span></code>, both results
are then returned.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.distributedmodules.sdm_groebner">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.distributedmodules.</span></span><span class="sig-name descname"><span class="pre">sdm_groebner</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">G</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">NF</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">O</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">K</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extended</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/distributedmodules.py#L599-L738"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.distributedmodules.sdm_groebner" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute a minimal standard basis of <code class="docutils literal notranslate"><span class="pre">G</span></code> with respect to order <code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p>The algorithm uses a normal form <code class="docutils literal notranslate"><span class="pre">NF</span></code>, for example <code class="docutils literal notranslate"><span class="pre">sdm_nf_mora</span></code>.
The ground field is assumed to be <code class="docutils literal notranslate"><span class="pre">K</span></code>, and monomials ordered according
to <code class="docutils literal notranslate"><span class="pre">O</span></code>.</p>
<p>Let <span class="math notranslate nohighlight">\(N\)</span> denote the submodule generated by elements of <span class="math notranslate nohighlight">\(G\)</span>. A standard
basis for <span class="math notranslate nohighlight">\(N\)</span> is a subset <span class="math notranslate nohighlight">\(S\)</span> of <span class="math notranslate nohighlight">\(N\)</span>, such that <span class="math notranslate nohighlight">\(in(S) = in(N)\)</span>, where for
any subset <span class="math notranslate nohighlight">\(X\)</span> of <span class="math notranslate nohighlight">\(F\)</span>, <span class="math notranslate nohighlight">\(in(X)\)</span> denotes the submodule generated by the
initial forms of elements of <span class="math notranslate nohighlight">\(X\)</span>. [SCA, defn 2.3.2]</p>
<p>A standard basis is called minimal if no subset of it is a standard basis.</p>
<p>One may show that standard bases are always generating sets.</p>
<p>Minimal standard bases are not unique. This algorithm computes a
deterministic result, depending on the particular order of <span class="math notranslate nohighlight">\(G\)</span>.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">extended=True</span></code>, also compute the transition matrix from the initial
generators to the groebner basis. That is, return a list of coefficient
vectors, expressing the elements of the groebner basis in terms of the
elements of <code class="docutils literal notranslate"><span class="pre">G</span></code>.</p>
<p>This functions implements the “sugar” strategy, see</p>
<p>Giovini et al: “One sugar cube, please” OR Selection strategies in
Buchberger algorithm.</p>
</dd></dl>

</section>
</section>
<section id="module-sympy.polys.polyoptions">
<span id="options"></span><h2>Options<a class="headerlink" href="#module-sympy.polys.polyoptions" title="Permalink to this headline">¶</a></h2>
<p>Options manager for <a class="reference internal" href="reference.html#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a> and public API functions.</p>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyoptions.Options">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyoptions.</span></span><span class="sig-name descname"><span class="pre">Options</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyoptions.py#L77-L255"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyoptions.Options" title="Permalink to this definition">¶</a></dt>
<dd><p>Options manager for polynomial manipulation module.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyoptions</span> <span class="kn">import</span> <span class="n">Options</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.polyoptions</span> <span class="kn">import</span> <span class="n">build_options</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Options</span><span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">),</span> <span class="p">{</span><span class="s1">&#39;domain&#39;</span><span class="p">:</span> <span class="s1">&#39;ZZ&#39;</span><span class="p">})</span>
<span class="go">{&#39;auto&#39;: False, &#39;domain&#39;: ZZ, &#39;gens&#39;: (x, y, z)}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">build_options</span><span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">),</span> <span class="p">{</span><span class="s1">&#39;domain&#39;</span><span class="p">:</span> <span class="s1">&#39;ZZ&#39;</span><span class="p">})</span>
<span class="go">{&#39;auto&#39;: False, &#39;domain&#39;: ZZ, &#39;gens&#39;: (x, y, z)}</span>
</pre></div>
</div>
<p><strong>Options</strong></p>
<ul class="simple">
<li><p>Expand — boolean option</p></li>
<li><p>Gens — option</p></li>
<li><p>Wrt — option</p></li>
<li><p>Sort — option</p></li>
<li><p>Order — option</p></li>
<li><p>Field — boolean option</p></li>
<li><p>Greedy — boolean option</p></li>
<li><p>Domain — option</p></li>
<li><p>Split — boolean option</p></li>
<li><p>Gaussian — boolean option</p></li>
<li><p>Extension — option</p></li>
<li><p>Modulus — option</p></li>
<li><p>Symmetric — boolean option</p></li>
<li><p>Strict — boolean option</p></li>
</ul>
<p><strong>Flags</strong></p>
<ul class="simple">
<li><p>Auto — boolean flag</p></li>
<li><p>Frac — boolean flag</p></li>
<li><p>Formal — boolean flag</p></li>
<li><p>Polys — boolean flag</p></li>
<li><p>Include — boolean flag</p></li>
<li><p>All — boolean flag</p></li>
<li><p>Gen — flag</p></li>
<li><p>Series — boolean flag</p></li>
</ul>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.polyoptions.Options.clone">
<span class="sig-name descname"><span class="pre">clone</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">updates</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyoptions.py#L206-L216"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyoptions.Options.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>Clone <code class="docutils literal notranslate"><span class="pre">self</span></code> and update specified options.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyoptions.build_options">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyoptions.</span></span><span class="sig-name descname"><span class="pre">build_options</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">gens</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyoptions.py#L741-L749"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyoptions.build_options" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct options from keyword arguments or … options.</p>
</dd></dl>

</section>
<section id="module-sympy.polys.polyconfig">
<span id="configuration"></span><h2>Configuration<a class="headerlink" href="#module-sympy.polys.polyconfig" title="Permalink to this headline">¶</a></h2>
<p>Configuration utilities for polynomial manipulation algorithms.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.polyconfig.setup">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.polyconfig.</span></span><span class="sig-name descname"><span class="pre">setup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyconfig.py#L37-L44"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyconfig.setup" title="Permalink to this definition">¶</a></dt>
<dd><p>Assign a value to (or reset) a configuration item.</p>
</dd></dl>

</section>
<section id="exceptions">
<h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h2>
<p>These are exceptions defined by the polynomials module.</p>
<p>TODO sort and explain</p>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.BasePolynomialError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">BasePolynomialError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L6-L11"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.BasePolynomialError" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for polynomial related exceptions.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.ExactQuotientFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">ExactQuotientFailed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dom</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L13-L28"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.ExactQuotientFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.OperationNotSupported">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">OperationNotSupported</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">poly</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L57-L65"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.OperationNotSupported" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.HeuristicGCDFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">HeuristicGCDFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L67-L69"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.HeuristicGCDFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.HomomorphismFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">HomomorphismFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L74-L76"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.HomomorphismFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.IsomorphismFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">IsomorphismFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L78-L80"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.IsomorphismFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.ExtraneousFactors">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">ExtraneousFactors</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L82-L84"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.ExtraneousFactors" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.EvaluationFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">EvaluationFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L86-L88"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.EvaluationFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.RefinementFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">RefinementFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L90-L92"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.RefinementFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.CoercionFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">CoercionFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L94-L96"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.CoercionFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.NotInvertible">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">NotInvertible</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L98-L100"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.NotInvertible" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.NotReversible">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">NotReversible</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L102-L104"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.NotReversible" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.NotAlgebraic">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">NotAlgebraic</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L106-L108"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.NotAlgebraic" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.DomainError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">DomainError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L110-L112"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.DomainError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.PolynomialError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">PolynomialError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L114-L116"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.PolynomialError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.UnificationFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">UnificationFailed</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L118-L120"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.UnificationFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.GeneratorsNeeded">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">GeneratorsNeeded</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L126-L128"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.GeneratorsNeeded" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.ComputationFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">ComputationFailed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nargs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exc</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L130-L139"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.ComputationFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.GeneratorsError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">GeneratorsError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L122-L124"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.GeneratorsError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.UnivariatePolynomialError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">UnivariatePolynomialError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L141-L143"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.UnivariatePolynomialError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.MultivariatePolynomialError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">MultivariatePolynomialError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L145-L147"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.MultivariatePolynomialError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.PolificationFailed">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">PolificationFailed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">opt</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">origs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exprs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seq</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L149-L169"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.PolificationFailed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.OptionError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">OptionError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L171-L173"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.OptionError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.polyerrors.FlagError">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.polyerrors.</span></span><span class="sig-name descname"><span class="pre">FlagError</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/polyerrors.py#L175-L177"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.polyerrors.FlagError" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</section>
<section id="reference">
<h2>Reference<a class="headerlink" href="#reference" title="Permalink to this headline">¶</a></h2>
<section id="modular-gcd">
<h3>Modular GCD<a class="headerlink" href="#modular-gcd" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.modulargcd.modgcd_univariate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.modulargcd.</span></span><span class="sig-name descname"><span class="pre">modgcd_univariate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/modulargcd.py#L156-L282"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.modulargcd.modgcd_univariate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the GCD of two polynomials in <span class="math notranslate nohighlight">\(\mathbb{Z}[x]\)</span> using a modular
algorithm.</p>
<p>The algorithm computes the GCD of two univariate integer polynomials
<span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> by computing the GCD in <span class="math notranslate nohighlight">\(\mathbb{Z}_p[x]\)</span> for suitable
primes <span class="math notranslate nohighlight">\(p\)</span> and then reconstructing the coefficients with the Chinese
Remainder Theorem. Trial division is only made for candidates which
are very likely the desired GCD.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : PolyElement</p>
<blockquote>
<div><p>univariate integer polynomial</p>
</div></blockquote>
<p><strong>g</strong> : PolyElement</p>
<blockquote>
<div><p>univariate integer polynomial</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>h</strong> : PolyElement</p>
<blockquote>
<div><p>GCD of the polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
</div></blockquote>
<p><strong>cff</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(f\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{f}{h}\)</span></p>
</div></blockquote>
<p><strong>cfg</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(g\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{g}{h}\)</span></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.modulargcd</span> <span class="kn">import</span> <span class="n">modgcd_univariate</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">5</span> <span class="o">-</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">-</span> <span class="mi">1</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_univariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(x - 1, x**4 + x**3 + x**2 + x + 1, 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">6</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_univariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(2*x + 2, 3*x - 3, x + 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#monagan00" id="id35"><span>[Monagan00]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.modulargcd.modgcd_bivariate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.modulargcd.</span></span><span class="sig-name descname"><span class="pre">modgcd_bivariate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/modulargcd.py#L697-L906"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.modulargcd.modgcd_bivariate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the GCD of two polynomials in <span class="math notranslate nohighlight">\(\mathbb{Z}[x, y]\)</span> using a
modular algorithm.</p>
<p>The algorithm computes the GCD of two bivariate integer polynomials
<span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> by calculating the GCD in <span class="math notranslate nohighlight">\(\mathbb{Z}_p[x, y]\)</span> for
suitable primes <span class="math notranslate nohighlight">\(p\)</span> and then reconstructing the coefficients with the
Chinese Remainder Theorem. To compute the bivariate GCD over
<span class="math notranslate nohighlight">\(\mathbb{Z}_p\)</span>, the polynomials <span class="math notranslate nohighlight">\(f \; \mathrm{mod} \, p\)</span> and
<span class="math notranslate nohighlight">\(g \; \mathrm{mod} \, p\)</span> are evaluated at <span class="math notranslate nohighlight">\(y = a\)</span> for certain
<span class="math notranslate nohighlight">\(a \in \mathbb{Z}_p\)</span> and then their univariate GCD in <span class="math notranslate nohighlight">\(\mathbb{Z}_p[x]\)</span>
is computed. Interpolating those yields the bivariate GCD in
<span class="math notranslate nohighlight">\(\mathbb{Z}_p[x, y]\)</span>. To verify the result in <span class="math notranslate nohighlight">\(\mathbb{Z}[x, y]\)</span>, trial
division is done, but only for candidates which are very likely the
desired GCD.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : PolyElement</p>
<blockquote>
<div><p>bivariate integer polynomial</p>
</div></blockquote>
<p><strong>g</strong> : PolyElement</p>
<blockquote>
<div><p>bivariate integer polynomial</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>h</strong> : PolyElement</p>
<blockquote>
<div><p>GCD of the polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
</div></blockquote>
<p><strong>cff</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(f\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{f}{h}\)</span></p>
</div></blockquote>
<p><strong>cfg</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(g\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{g}{h}\)</span></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.modulargcd</span> <span class="kn">import</span> <span class="n">modgcd_bivariate</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x, y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_bivariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(x + y, x - y, x + y)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">4</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_bivariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(x + 2, x*y - x - 2*y + 2, 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#monagan00" id="id37"><span>[Monagan00]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.modulargcd.modgcd_multivariate">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.modulargcd.</span></span><span class="sig-name descname"><span class="pre">modgcd_multivariate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/modulargcd.py#L1062-L1206"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.modulargcd.modgcd_multivariate" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the GCD of two polynomials in <span class="math notranslate nohighlight">\(\mathbb{Z}[x_0, \ldots, x_{k-1}]\)</span>
using a modular algorithm.</p>
<p>The algorithm computes the GCD of two multivariate integer polynomials
<span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> by calculating the GCD in
<span class="math notranslate nohighlight">\(\mathbb{Z}_p[x_0, \ldots, x_{k-1}]\)</span> for suitable primes <span class="math notranslate nohighlight">\(p\)</span> and then
reconstructing the coefficients with the Chinese Remainder Theorem. To
compute the multivariate GCD over <span class="math notranslate nohighlight">\(\mathbb{Z}_p\)</span> the recursive
subroutine <a class="reference internal" href="#sympy.polys.modulargcd._modgcd_multivariate_p" title="sympy.polys.modulargcd._modgcd_multivariate_p"><code class="xref py py-func docutils literal notranslate"><span class="pre">_modgcd_multivariate_p()</span></code></a> is used. To verify the result in
<span class="math notranslate nohighlight">\(\mathbb{Z}[x_0, \ldots, x_{k-1}]\)</span>, trial division is done, but only for
candidates which are very likely the desired GCD.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : PolyElement</p>
<blockquote>
<div><p>multivariate integer polynomial</p>
</div></blockquote>
<p><strong>g</strong> : PolyElement</p>
<blockquote>
<div><p>multivariate integer polynomial</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>h</strong> : PolyElement</p>
<blockquote>
<div><p>GCD of the polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
</div></blockquote>
<p><strong>cff</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(f\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{f}{h}\)</span></p>
</div></blockquote>
<p><strong>cfg</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(g\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac{g}{h}\)</span></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.modulargcd</span> <span class="kn">import</span> <span class="n">modgcd_multivariate</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">ring</span><span class="p">,</span> <span class="n">ZZ</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x, y&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_multivariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(x + y, x - y, x + y)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s2">&quot;x, y, z&quot;</span><span class="p">,</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="n">z</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="n">y</span><span class="o">*</span><span class="n">z</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">z</span> <span class="o">+</span> <span class="n">z</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">modgcd_multivariate</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span>
<span class="go">(z, x*z - y*z, x**2 + 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.modulargcd._modgcd_multivariate_p" title="sympy.polys.modulargcd._modgcd_multivariate_p"><code class="xref py py-obj docutils literal notranslate"><span class="pre">_modgcd_multivariate_p</span></code></a></p>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#monagan00" id="id39"><span>[Monagan00]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#brown71" id="id40"><span>[Brown71]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.modulargcd._modgcd_multivariate_p">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.modulargcd.</span></span><span class="sig-name descname"><span class="pre">_modgcd_multivariate_p</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degbound</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contbound</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/modulargcd.py#L909-L1059"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.modulargcd._modgcd_multivariate_p" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the GCD of two polynomials in
<span class="math notranslate nohighlight">\(\mathbb{Z}_p[x_0, \ldots, x_{k-1}]\)</span>.</p>
<p>The algorithm reduces the problem step by step by evaluating the
polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> at <span class="math notranslate nohighlight">\(x_{k-1} = a\)</span> for suitable
<span class="math notranslate nohighlight">\(a \in \mathbb{Z}_p\)</span> and then calls itself recursively to compute the GCD
in <span class="math notranslate nohighlight">\(\mathbb{Z}_p[x_0, \ldots, x_{k-2}]\)</span>. If these recursive calls are
successful for enough evaluation points, the GCD in <span class="math notranslate nohighlight">\(k\)</span> variables is
interpolated, otherwise the algorithm returns <code class="docutils literal notranslate"><span class="pre">None</span></code>. Every time a GCD
or a content is computed, their degrees are compared with the bounds. If
a degree greater then the bound is encountered, then the current call
returns <code class="docutils literal notranslate"><span class="pre">None</span></code> and a new evaluation point has to be chosen. If at some
point the degree is smaller, the correspondent bound is updated and the
algorithm fails.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : PolyElement</p>
<blockquote>
<div><p>multivariate integer polynomial with coefficients in <span class="math notranslate nohighlight">\(\mathbb{Z}_p\)</span></p>
</div></blockquote>
<p><strong>g</strong> : PolyElement</p>
<blockquote>
<div><p>multivariate integer polynomial with coefficients in <span class="math notranslate nohighlight">\(\mathbb{Z}_p\)</span></p>
</div></blockquote>
<p><strong>p</strong> : Integer</p>
<blockquote>
<div><p>prime number, modulus of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
</div></blockquote>
<p><strong>degbound</strong> : list of Integer objects</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">degbound[i]</span></code> is an upper bound for the degree of the GCD of <span class="math notranslate nohighlight">\(f\)</span>
and <span class="math notranslate nohighlight">\(g\)</span> in the variable <span class="math notranslate nohighlight">\(x_i\)</span></p>
</div></blockquote>
<p><strong>contbound</strong> : list of Integer objects</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">contbound[i]</span></code> is an upper bound for the degree of the content of
the GCD in <span class="math notranslate nohighlight">\(\mathbb{Z}_p[x_i][x_0, \ldots, x_{i-1}]\)</span>,
<code class="docutils literal notranslate"><span class="pre">contbound[0]</span></code> is not used can therefore be chosen
arbitrarily.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>h</strong> : PolyElement</p>
<blockquote>
<div><p>GCD of the polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> or <code class="docutils literal notranslate"><span class="pre">None</span></code></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#monagan00" id="id43"><span>[Monagan00]</span></a></p></li>
<li><p><a class="reference internal" href="literature.html#brown71" id="id44"><span>[Brown71]</span></a></p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.polys.modulargcd.func_field_modgcd">
<span class="sig-prename descclassname"><span class="pre">sympy.polys.modulargcd.</span></span><span class="sig-name descname"><span class="pre">func_field_modgcd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">g</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/modulargcd.py#L2129-L2277"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.modulargcd.func_field_modgcd" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the GCD of two polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in
<span class="math notranslate nohighlight">\(\mathbb Q(\alpha)[x_0, \ldots, x_{n-1}]\)</span> using a modular algorithm.</p>
<p>The algorithm first computes the primitive associate
<span class="math notranslate nohighlight">\(\check m_{\alpha}(z)\)</span> of the minimal polynomial <span class="math notranslate nohighlight">\(m_{\alpha}\)</span> in
<span class="math notranslate nohighlight">\(\mathbb{Z}[z]\)</span> and the primitive associates of <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span> in
<span class="math notranslate nohighlight">\(\mathbb{Z}[x_1, \ldots, x_{n-1}][z]/(\check m_{\alpha})[x_0]\)</span>. Then it
computes the GCD in
<span class="math notranslate nohighlight">\(\mathbb Q(x_1, \ldots, x_{n-1})[z]/(m_{\alpha}(z))[x_0]\)</span>.
This is done by calculating the GCD in
<span class="math notranslate nohighlight">\(\mathbb{Z}_p(x_1, \ldots, x_{n-1})[z]/(\check m_{\alpha}(z))[x_0]\)</span> for
suitable primes <span class="math notranslate nohighlight">\(p\)</span> and then reconstructing the coefficients with the
Chinese Remainder Theorem and Rational Reconstuction. The GCD over
<span class="math notranslate nohighlight">\(\mathbb{Z}_p(x_1, \ldots, x_{n-1})[z]/(\check m_{\alpha}(z))[x_0]\)</span> is
computed with a recursive subroutine, which evaluates the polynomials at
<span class="math notranslate nohighlight">\(x_{n-1} = a\)</span> for suitable evaluation points <span class="math notranslate nohighlight">\(a \in \mathbb Z_p\)</span> and
then calls itself recursively until the ground domain does no longer
contain any parameters. For
<span class="math notranslate nohighlight">\(\mathbb{Z}_p[z]/(\check m_{\alpha}(z))[x_0]\)</span> the Euclidean Algorithm is
used. The results of those recursive calls are then interpolated and
Rational Function Reconstruction is used to obtain the correct
coefficients. The results, both in
<span class="math notranslate nohighlight">\(\mathbb Q(x_1, \ldots, x_{n-1})[z]/(m_{\alpha}(z))[x_0]\)</span> and
<span class="math notranslate nohighlight">\(\mathbb{Z}_p(x_1, \ldots, x_{n-1})[z]/(\check m_{\alpha}(z))[x_0]\)</span>, are
verified by a fraction free trial division.</p>
<p>Apart from the above GCD computation some GCDs in
<span class="math notranslate nohighlight">\(\mathbb Q(\alpha)[x_1, \ldots, x_{n-1}]\)</span> have to be calculated,
because treating the polynomials as univariate ones can result in
a spurious content of the GCD. For this <code class="docutils literal notranslate"><span class="pre">func_field_modgcd</span></code> is
called recursively.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f, g</strong> : PolyElement</p>
<blockquote>
<div><p>polynomials in <span class="math notranslate nohighlight">\(\mathbb Q(\alpha)[x_0, \ldots, x_{n-1}]\)</span></p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>h</strong> : PolyElement</p>
<blockquote>
<div><p>monic GCD of the polynomials <span class="math notranslate nohighlight">\(f\)</span> and <span class="math notranslate nohighlight">\(g\)</span></p>
</div></blockquote>
<p><strong>cff</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(f\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac f h\)</span></p>
</div></blockquote>
<p><strong>cfg</strong> : PolyElement</p>
<blockquote>
<div><p>cofactor of <span class="math notranslate nohighlight">\(g\)</span>, i.e. <span class="math notranslate nohighlight">\(\frac g h\)</span></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.modulargcd</span> <span class="kn">import</span> <span class="n">func_field_modgcd</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">AlgebraicField</span><span class="p">,</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">ring</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sqrt</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">AlgebraicField</span><span class="p">(</span><span class="n">QQ</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="n">A</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">func_field_modgcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">==</span> <span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">ring</span><span class="p">(</span><span class="s1">&#39;x, y&#39;</span><span class="p">,</span> <span class="n">A</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">func_field_modgcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">==</span> <span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">y</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span><span class="p">,</span> <span class="n">cff</span><span class="p">,</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">func_field_modgcd</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">h</span> <span class="o">==</span> <span class="n">R</span><span class="o">.</span><span class="n">one</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cff</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">f</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cfg</span> <span class="o">*</span> <span class="n">h</span> <span class="o">==</span> <span class="n">g</span>
<span class="go">True</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="literature.html#hoeij04" id="id47"><span>[Hoeij04]</span></a></p></li>
</ol>
</dd></dl>

</section>
</section>
<section id="undocumented">
<h2>Undocumented<a class="headerlink" href="#undocumented" title="Permalink to this headline">¶</a></h2>
<p>Many parts of the polys module are still undocumented, and even where there is
documentation it is scarce. Please contribute!</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Internals of the Polynomial Manipulation Module</a><ul>
<li><a class="reference internal" href="#level-zero">Level Zero</a><ul>
<li><a class="reference internal" href="#manipulation-of-dense-multivariate-polynomials">Manipulation of dense, multivariate polynomials</a></li>
<li><a class="reference internal" href="#manipulation-of-dense-univariate-polynomials-with-finite-field-coefficients">Manipulation of dense, univariate polynomials with finite field coefficients</a></li>
<li><a class="reference internal" href="#manipulation-of-sparse-distributed-polynomials-and-vectors">Manipulation of sparse, distributed polynomials and vectors</a></li>
<li><a class="reference internal" href="#polynomial-factorization-algorithms">Polynomial factorization algorithms</a><ul>
<li><a class="reference internal" href="#classical-remainder-sequence">Classical remainder sequence</a></li>
<li><a class="reference internal" href="#simplified-remainder-sequences">Simplified remainder sequences</a></li>
<li><a class="reference internal" href="#subresultant-sequence">Subresultant sequence</a></li>
</ul>
</li>
<li><a class="reference internal" href="#groebner-basis-algorithms">Groebner basis algorithms</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sympy.polys.polyoptions">Options</a></li>
<li><a class="reference internal" href="#module-sympy.polys.polyconfig">Configuration</a></li>
<li><a class="reference internal" href="#exceptions">Exceptions</a></li>
<li><a class="reference internal" href="#reference">Reference</a><ul>
<li><a class="reference internal" href="#modular-gcd">Modular GCD</a></li>
</ul>
</li>
<li><a class="reference internal" href="#undocumented">Undocumented</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="domainsref.html"
                        title="previous chapter">Reference docs for the Poly Domains</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="ringseries.html"
                        title="next chapter">Series Manipulation using Polynomials</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/polys/internals.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ringseries.html" title="Series Manipulation using Polynomials"
             >next</a> |</li>
        <li class="right" >
          <a href="domainsref.html" title="Reference docs for the Poly Domains"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Internals of the Polynomial Manipulation Module</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/polys/internals.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:28:05 GMT -->
</html>